Skip to content
C

Group Anagrams

Mediumjavapythonccppjavascript

Given a list of words, group together the words that are anagrams of each other.

Input Format

The first line contains an integer K, the number of words. Each of the next K lines contains one lowercase word with no spaces.

Output Format

Print one line per group. Within a group, keep the words in input order, separated by single spaces. Order the groups by the first appearance of any of their members.

Input (stdin)

Output

Run your code to see output here...