LearnPy Hub
← Dictionaries problems
Hard

Anagram Groups

Read a line of words. Group words that are anagrams of each other. Print each group on its own line (words in input order), with groups ordered by the first appearance of their first word.

Input

One line.

Output

One line per group.

Sample 1

Input
eat tea tan ate nat bat
Output
eat tea ate
tan nat
bat

Sample 2

Input
a b a
Output
a a
b
solution.py
Output appears here
Anagram Groups · Python practice problem · LearnPy Hub