시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 20 13 13 81.250%

문제

두 정수가 만약에 완전히 같은 숫자들로만 이루어져 있으면 두 숫자를 friends(친구)라고 부른다. 예를 들어 123과 32331313323213은 friends 이지만 123과 22121221은 아니다.

그러나 friends가 아닌 두 개의 정수가 만약에 이웃한 두 숫자를 규칙에 따라 고쳤을 때 friends가 되면 almost friends(거의 친구)라고 부른다. 그 규칙은 만약에 a와 b가 붙어 있으면 a에 1을 빼고 b에 1을 더하거나 a에 1을 더하고 b에 1을 뺄 수 있다는 것이다. 하지만 그 결과에서 맨 앞자리 숫자가 0이라면 이것은 허용이 되지 않는다. 예를 들어 123과 2223042는 almost friends이다. (2223042 -> 2223132) 하지만 137과 470은 friends도 almost friends도 아니다. (137 -> 047)은 허용이 되지 않는다. 연산은 두 수 중 하나에게만, 최대 한 번 사용할 수 있다.

만약에 두 정수가 주어져 있을 때, 두 정수가 friends인지, almost friends인지, 아니면 아무것도 아닌지 구하는 프로그램을 작성하시오.

입력

세 개의 입력 데이터가 주어지며, 각각의 입력 데이터는 한 개의 줄로 이루어져 있다. 각 데이터의 첫째 줄에 두 정수 x,y가 공백을 사이에 두고 주어진다.(0<x,y<10^100)

출력

세 개의 줄에 걸쳐 입력된 순서대로 x,y가 friends면 “friends", almost friends이면 ”almost friends", 둘 다 아니면 “nothing" 이라고 출력한다.

예제 입력 1

123 32331313323213
137 470
123 2223042

예제 출력 1

friends
nothing
almost friends
W3sicHJvYmxlbV9pZCI6IjE5ODUiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWI1MTRcdWM5YzBcdWQxMzggXHVjZTVjXHVhZDZjIiwiZGVzY3JpcHRpb24iOiI8cD5cdWI0NTAgXHVjODE1XHVjMjE4XHVhYzAwIFx1YjljY1x1YzU3ZFx1YzVkMCBcdWM2NDRcdWM4MDRcdWQ3ODggXHVhYzE5XHVjNzQwIFx1YzIyYlx1Yzc5MFx1YjRlNFx1Yjg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