#C14295. Find Anagrams in a List

    ID: 43928 Type: Default 1000ms 256MiB

Find Anagrams in a List

Find Anagrams in a List

Given a list of words, your task is to identify and print all words which have at least one anagram also present in the list. Two words are considered anagrams if when sorted by their characters, they are identical. The order of the output should follow the order in which the words appear in the input.

Note: A word is considered an anagram only if there is another word in the list that is an anagram of it. If no words satisfy this condition, output an empty line.

Example:

Input:
3
bat
tab
cat

Output: bat tab

</p>

inputFormat

The first line of the input contains an integer n indicating the number of words. The following n lines each contain a single word.

outputFormat

Print all the words (separated by a space) that have at least one anagram in the input, preserving their original order. If no such words exist, print an empty line.

## sample
3
bat
tab
cat
bat tab

</p>