#K69017. Rank Students by Score

    ID: 32993 Type: Default 1000ms 256MiB

Rank Students by Score

Rank Students by Score

You are given the number of students n and a list of student records. Each record contains a student ID and a score.

Your task is to rank the students based on their scores in descending order. The student(s) with the highest score receive rank 1. If multiple students have the same score, they receive the same rank, and the next distinct score is assigned a rank according to its position in the sorted order (i.e. if two students are tied at rank 1, the next rank will be 3, not 2).

The output should list the original student IDs along with their corresponding ranks in the same order as the input.

The ranking rule in mathematical notation is as follows:

\[ \text{rank}(s_i) = 1 + \text{number of students with score greater than } s_i \] where \(s_i\) is the score of the i-th student in the sorted order.

inputFormat

The first line contains an integer n (1 ≤ n ≤ 105), the number of students.

The next n lines each contain two integers separated by a space: ID (a unique student identification number) and score (an integer score where higher is better).

outputFormat

Output n lines. Each line should contain two integers: the student ID and their corresponding rank, in the same order as the input.

## sample
5
101 93
102 89
103 89
104 94
105 91
101 2

102 4 103 4 104 1 105 3

</p>