#K47677. Group Anagrams
Group Anagrams
Group Anagrams
Given a list of strings, group the anagrams together. Two strings are anagrams if they contain the same characters in any order. The grouping must follow the order in which the anagram group first appears in the input.
For example, if the input is:
6 eat tea tan ate nat bat
then the output should be:
eat tea ate tan nat bat
Note: The input is read from standard input and the output should be printed to standard output. Each group is printed on a new line with the words separated by a single space.
inputFormat
The first line contains a positive integer n, denoting the number of strings. The following n lines each contain a string consisting of lowercase letters. A string can be empty.
outputFormat
Output several lines. Each line contains one group of anagrams, with the words separated by a single space. Groups must be output in the same order as their first occurrence based on their anagram key in the input.
## sample6
eat
tea
tan
ate
nat
bat
eat tea ate
tan nat
bat
</p>