#K80477. Anagram Pair Detection
Anagram Pair Detection
Anagram Pair Detection
Given a list of words, determine if any two distinct words are anagrams of each other. Two words are anagrams if one can be rearranged to form the other. Formally, for any two words (a) and (b), they are anagrams if (sort(a) = sort(b)). Your task is to check if at least one pair of words in the list is an anagram pair.
inputFormat
The input is read from standard input (stdin). The first line consists of an integer (T) representing the number of test cases. For each test case, the first line contains an integer (N) indicating the number of words. This is followed by (N) lines, each containing one word.
outputFormat
For each test case, output a single line containing either "YES" if there exists at least one pair of distinct words that are anagrams of each other, or "NO" otherwise. The output should be written to standard output (stdout).## sample
2
4
listen
silent
enlist
google
3
cat
dog
tac
YES
YES
</p>