#K42042. Group Anagrams of Order Names

    ID: 26999 Type: Default 1000ms 256MiB

Group Anagrams of Order Names

Group Anagrams of Order Names

You are given a list of order names. Two order names are considered anagrams if one can be rearranged to form the other. Your task is to group the order names into groups of anagrams.

For consistency, after grouping, you must sort the words within each group in lexicographical order, and then sort the groups based on the lexicographical order of their first word. Finally, output each group on a separate line, with words separated by a single space.

It is guaranteed that the list of order names will only consist of lowercase English letters. This problem is designed to test your ability to work with strings and basic sorting techniques.

inputFormat

The input is read from standard input (stdin) and consists of multiple lines. The first line contains an integer n representing the number of order names. Each of the following n lines contains a single order name.

outputFormat

Print the groups of anagrams, one group per line. In each line, print the order names in lexicographical order separated by a single space. The groups themselves must be printed in ascending order based on the first word of each group.

## sample
3
duel
dule
deul
deul duel dule

</p>