Hide

Problem C
Language Count

We want to make a dictionary of a few languages. This will involve grouping given words into what language they are and what they mean. We want to know how many words of each language we have and how many different translations of each word we have in order to measure completeness.

Input

The input file will consist of at most 2500 lines. The first line will contain the number of lines to follow, and each subsequent line will contain three words separated by spaces. All words will be in ASCII characters. Neither meanings nor words contain spaces.

Each of these lines describes a word from another language. The first word in the line will be the language from which the word originates, and the second word will be the word itself. The last word will be the English translation. If a word has a gender associated with it, then the gender will be indicated by parentheses at the end of the third word. However the word should be grouped according to its English meaning, regardless of any gender indicated. No two lines will be duplicates of each other.

Output

The output should consist of multiple lines. Each line should contain the original word, followed by the count of different words from other languages that were given as a translation for that word. The lines in the output should be presented in alphabetical order.

Sample Input 1 Sample Output 1
3
Georgian Lamazo Beauty
French Fenetre Window
Italian Bella Beauty(f)

Beauty 2
Window 1

Please log in to submit a solution to this problem

Log in