#C1712. Anagram Sets Finder

    ID: 44948 Type: Default 1000ms 256MiB

Anagram Sets Finder

Anagram Sets Finder

Given a list of words, your task is to find all sets of anagrams in the list. Two words are anagrams if one can be rearranged to form the other. For each set that contains at least two words, output the words in lexicographical order (i.e. sorted alphabetically) and join them with a single space. Then, sort all such groups in increasing order based on the first word in each group.

If no anagram sets exist, output No anagrams found.

Recall that if a word is represented by \(w\), its sorted form is \(sort(w)\). Two words \(w_1\) and \(w_2\) are anagrams if \(sort(w_1) = sort(w_2)\).

inputFormat

The input is given via standard input (stdin) in the following format:

N
word1 word2 ... wordN

Where N is an integer representing the number of words. The next line contains N words separated by spaces.

outputFormat

Output the anagram groups, one group per line. Each group should list the anagrams separated by a single space in lexicographical order. The groups themselves must be sorted in increasing order based on their first word. If there is no group of anagrams, print exactly No anagrams found.

## sample
5
listen silent enlist inlets apple
enlist inlets listen silent

</p>