beecrowd | 2312

Medal Table

By Leonardo Fernandes, IFSC BR Brazil

Timelimit: 1

Somebody messed up the olympic medal table. Your program must put it back in the right order. The order of the countries in the medal table is given by the number of gold medals. If there's a tie in the number of gold medals, than the country with more silver medals win. If there's a tie in both gold and silver medals, the country with more bronze medals should be above. If two or more nations tie in the three kinds of medals, your program must show them in alphabetic order.

Input

Input is the number of participating nations N (0 ≤ N ≤ 500), followed by the list of countries and their gold G (0 ≤ G ≤ 10000), silver S (0 ≤ S ≤ 10000) and bronze B (0 ≤ B ≤ 10000) medals.

Output

Output should be the list of countries and their gold, silver and bronze medals shown in the specified order.

Input Sample Output Sample

8
Belgica 2 2 2
Brasil 7 6 6
Franca 10 18 14
Italia 8 12 8
Australia 8 11 10
Colombia 3 2 3
Suica 3 2 2
Tailandia 2 2 2

Franca 10 18 14
Italia 8 12 8
Australia 8 11 10
Brasil 7 6 6
Colombia 3 2 3
Suica 3 2 2
Belgica 2 2 2
Tailandia 2 2 2