Module: (Python) Workshop - 7. Lilo and Stitch's rules of life


Problem

5 /5


Everyone is entitled to a second chance

Problem

Stitch is a genetic experiment 626 created by the evil genius Jumba Jookiba. And no matter how cute Stitch turned out at the end of the experiment, Jumbo still saw the destructive potential in him and continued to work on him. But before finishing work on Stitch, they were both detained by the Galactic Police.
Stitch was sentenced by the Supreme Councilor to life exile on a desert asteroid, but along the way he escapes and ends up on our planet on the Hawaiian island Kauai, where Lilo's love and care turned an evil alien into a kind and sympathetic friend! Jumbo Jukibo -  ; an alien from the planet Kviltakuan (Kweltikwan). He was sent to Earth to capture Experiment 626. In order for the mission to take place, Jumbo had to learn English. To do this, he created an English-Quiltaqua dictionary. For every English word he encountered, Jumbo recorded a few Quiltaquan translations words into his dictionary.
Unfortunately, he realized late that he also needed a Quiltaqua-English dictionary. He decided to make a Quiltaquan-English dictionary from an English-Quiltaquan during the flight. 
For each Quiltaquan word that appears in the dictionary, Jumbo wants to find all its translations (that is, all English words for which a Quiltaquan word has appeared in its list of translations) and treat them, and only them, as translations of that Quiltaquan word.
Help Jumbo complete the work of creating a Quiltaquan-English dictionary so that he can learn it by the time he arrives on our planet.

Input
The first line contains a single integer N — the number of English words in the dictionary. This is followed by N descriptions. Each description is on a separate line, with the English word first, followed by a space-separated hyphen (character number 45), then comma-and-space-separated translations of that English word into Quiltaquan. Translations are sorted in lexicographic order. The order of English words in the dictionary is also lexicographic.
All words consist only of small Latin letters, the length of each word does not exceed 15 characters. The total number of words in the input does not exceed 100,000.

Imprint
Output the corresponding Quiltaquan-English dictionary, following exactly the format of the input data. In particular, the translation of the lexicographically minimal Quiltakuan word should come first, followed by — the second in that order, and so on. Within the translation, English words must also be sorted lexicographically.

 

Examples
# Input Output
1 3
apple - malum, pomum, popula
fruit - baca, bacca, popum
punishment - malum, multa
7
baca-fruit
bacca-fruit
malum - apple, punishment
multa-punishment
pomum-apple
popula-apple
popum-fruit