#C9032. Find All Anagrams

    ID: 53081 Type: Default 1000ms 256MiB

Find All Anagrams

Find All Anagrams

You are given a list of words. Your task is to find all words that have at least one anagram in the list. Two words are anagrams if one can be rearranged to form the other. The output should be the collection of all such words, sorted in alphabetical order.

For example, given the words abc, bca, cab, each of these words has an anagram present in the list, so they all should appear in the output.

inputFormat

The input is read from standard input. The first line contains a single integer n (1 ≤ n ≤ 105), which indicates the number of words. Each of the following n lines contains a word consisting of lowercase letters.

outputFormat

Print the list of words (separated by a single space) that have at least one anagram in the list, in alphabetical order. If no such words exist, print an empty line.

## sample
6
abc
bca
cab
xyz
yzx
pqr
abc bca cab xyz yzx

</p>