시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 1640 796 669 52.844%

문제

두 단어 A와 B가 주어졌을 때, A에 속하는 알파벳의 순서를 바꾸어서 B를 만들 수 있다면, A와 B를 애너그램이라고 한다.

두 단어가 애너그램인지 아닌지 구하는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수(<100)가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, 길이가 100을 넘지 않는 단어가 공백으로 구분되어서 주어진다. 단어는 알파벳 소문자로만 이루어져 있다.

출력

각 테스트 케이스마다 애너그램인지 아닌지를 예체 출력과 같은 형식으로 출력한다. 

예제 입력 1

3
blather reblath
maryland landam
bizarre brazier

예제 출력 1

blather & reblath are anagrams.
maryland & landam are NOT anagrams.
bizarre & brazier are anagrams.
W3sicHJvYmxlbV9pZCI6IjY5OTYiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM1NjBcdWIxMDhcdWFkZjhcdWI3YTgiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YjQ1MCBcdWIyZThcdWM1YjQgQVx1YzY0MCBCXHVhYzAwIFx1YzhmY1x1YzViNFx1Yzg0Y1x1Yzc0NCBcdWI1NGMsIEFcdWM1ZDAgXHVjMThkXHVkNTU4XHViMjk0IFx1YzU0Y1x1ZDMwY1x1YmNiM1x1Yzc1OCBcdWMyMWNcdWMxMWNcdWI5N2MgXHViYzE0XHVhZmI4XHVjNWI0XHVjMTFjIEJcdWI5N2MgXHViOWNjXHViNGU0IFx1YzIxOCBcdWM3ODhcdWIyZTRcdWJhNzQsIEFcdWM2NDAgQlx1Yjk3YyBcdWM1NjBcdWIxMDhcdWFkZjhcdWI3YThcdWM3NzRcdWI3N2NcdWFjZTAgXHVkNTVjXHViMmU0LjxcL3A+XHJcblxyXG48cD5cdWI0NTAgXHViMmU4XHVjNWI0XHVhYzAwIFx1YzU2MFx1YjEwOFx1YWRmOFx1YjdhOFx1Yzc3OFx1YzljMCBcdWM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