In this Urja my dear friend Shrikant(SRI) got involved in the heat. Being a very bright coder he was also given a job to handle the stats of the event. His job was as follows:
Every event has three prizes gold, silver, bronze. Outcome of a event is given in a format of string as "GGG SSS BBB" where three letter substring denote the name of the player who got the position.
For instance "RAH BUD TAN" then gold went to player "RAH", silver to "BUD" and bronze to "TAN".
SRI's job is simple, he has to give final medal record of each player in this format: "NNN GGG SSS BBB", where NNN denotes the name of player as mentioned above, GGG SSS BBB is the number of gold, silver and bronze won by the player.
Finally the output consist of many strings each corresponding to a player participating in the event.
Also output need to be sorted by : first by number of golds, then by number of silver and then by number of bronze in decreasing order. If a tie occurs then put them according to their names in lexicographical (increasing) order.
As SRI is busy he has asked your help.
Input:
First line contains N, number of events.
Following N Lines follows giving outcome of different events in the format specified above.
Output:
It consist of number of lines equal to number of players. Each line will consist description of each player in the format specified.
Constraint:
0 < N <= 50
Number of total players never exceed 100.
Sample Input:
5
SRI BUD RAH
RAH BUD SRI
BUD RAH SRI
TAN RAJ SAC
SRI SAC RAJ
Sample Output:
SRI 2 0 2
BUD 1 2 0
RAH 1 1 1
TAN 1 0 0
RAJ 0 1 1
SAC 0 1 1