#C5258. Participant Ranking

    ID: 48887 Type: Default 1000ms 256MiB

Participant Ranking

Participant Ranking

You are given a list of participants. Each participant is represented by a tuple of three integers: the participant's ID, points, and registration time.

Your task is to calculate the rank of each participant. The ranking should be determined in the following way:

  • Participants with higher points get a better rank.
  • If two participants have the same points, the one with the earlier registration time (i.e. smaller value) gets a better rank.

Mathematically, if we denote a participant by \( (ID,\,p,\,t) \), the sorting key is given by:

\[ \text{key} = \bigl(-p,\, t\bigr) \]

After ranking, output each participant along with their rank in the order of increasing rank.

inputFormat

The first line of input contains an integer \( n \), the number of participants. Each of the following \( n \) lines contains three space separated integers: \( ID \), \( points \), and \( registration\ time \).

outputFormat

Output \( n \) lines. Each line should contain two integers: the participant's \( ID \) and their \( rank \), separated by a space. The participants must be listed in order of increasing rank (i.e. rank 1 first, then rank 2, and so on).

## sample
4
1 100 5
2 200 3
3 100 2
4 200 1
4 1

2 2 3 3 1 4

</p>