ClosedCup#2736

ClosedCup

1 second
64 megabytes
Medium

Bag Rockhead suspects a conspiracy among the commando penguins participating in the ClosedCup programming contest. Each team in the competition is represented by a name and a list of participants. A team name may appear multiple times in the data, possibly associated with different sets of participants over time.

Help Bag Rockhead compile, for each team name, a comprehensive list of all participants who have ever represented that team. Print the list of team names in lexicographical order. For each team, list the participants who have competed for that team at least once, in order of decreasing number of participations. If multiple participants have the same number of participations, list them in lexicographical order.

A string is lexicographically smaller than a string if either is a prefix of (and x \leq y), or there exists such (1 \leq i \leq \min(|x|, |y|)) that x_i < y_i, and for any (1 \leq j < i) x_j = y_j. Here denotes the length of string . Lexicographical comparison applies the operator as in modern programming languages.

Input

The first line contains a single integer (1 \leq N \leq 100\ 000) — the number of team records. The next lines describe the teams. Each record consists of a team name (composed of characters with codes from to except (:); the name is non-empty and at most characters long), followed by ": ", then a list of participants. Each participant is given either as a first name and last name (two non-empty words), or as a nickname (one non-empty word). Each word consists only of uppercase or lowercase Latin letters. For first name and last name, the words are separated by a single space. The list of participants consists of one, two, or three names, all distinct within a record. After each participant (except the last) is a comma and a space, and after the last participant is a period and a newline. The information about a participant (including space between first and last name, if present) does not exceed characters.

The input file size does not exceed one megabyte. The file always ends with an empty line.

Output

Print team descriptions, separated by empty lines. Each description consists of the team name, a colon, and a list of participants who have represented that team at least once. For each participant, print on a new line: four spaces, followed by the participant's full name or nickname, then a comma, a space, and the number of times this participant has competed for this team, followed by a period and a newline. List participants by decreasing number of participations, and lexicographically in case of ties.

Print team descriptions in lexicographical order of team names. There must be no extra empty lines in the output.

Examples

Example 1

Loading
Loading