Group words that are anagrams of each other.
Input
- Line 1: n (
1 ≤ n ≤ 10^4)
- Line 2: n lowercase words separated by spaces
Output
One group per line. Inside a group, words are sorted alphabetically and separated by single spaces. Groups are sorted by their first word.
Hint
The sorted letters of a word make a perfect group key: eat, tea and ate all become aet.
Read from standard input and write to standard output. 5 test cases in total (3 hidden). Tests for this language run inside your browser.