Competitions

# Week 10: January 18 - 24

# ACM Sort

You are the author of a testing system that sorts teams according to ACM rules. Ranked teams are ordered according to the following rules:

- by the number of solved problems in descending order;
- if the number of solved problems is equal - by the penalty time in ascending order;
- if all mentioned parameters are equal - by the team number in ascending order.

#### Input

First line contains the number of teams **n** (**1** ≤ **n** ≤ **1000**) that participate in competition. The information about **i**-th team is given in the **i**-th next line (**1** ≤ **i** ≤ **n**):

- the team name, no more than
**20**characters; - the number of solved problems
**s**(**0**≤**s**≤**100**) - the penalty time
**t**(**0**≤**t**≤**1000**) of the team.

#### Output

Print the information about the teams in sorted order as shown in the example.

Input example #1

6 Facebook 6 789 Google 5 123 E-olymp 7 345 IBM 7 340 Codeforces 5 54 Microsoft 5 123

Output example #1

IBM 7 340 E-olymp 7 345 Facebook 6 789 Codeforces 5 54 Google 5 123 Microsoft 5 123