#K83022. Group Anagrams
Group Anagrams
Group Anagrams
Given a list of strings, your task is to group the strings that are anagrams of each other. Two strings are anagrams if they contain the same characters in a different order. For each group, sort the strings in lexicographical order. Finally, sort the groups by the lexicographically smallest string in each group, and print each group on a separate line with the strings separated by a single space.
Note: Input is read from standard input (stdin) and output is written to standard output (stdout).
Example:
Input: 6 eat tea tan ate nat bat</p>Output: ate eat tea bat nat tan
inputFormat
The first line contains an integer n indicating the number of strings. The following n lines each contain a single string.
Input is provided via standard input.
outputFormat
Print the groups of anagrams. For each group, first sort the words in lexicographical order. Then sort the groups by the lexicographically smallest word in each group. Print each group on a new line with its words separated by a single space.
Output is written to standard output.
## sample6
eat
tea
tan
ate
nat
bat
ate eat tea
bat
nat tan
</p>