#C11930. Student Ranking

    ID: 41301 Type: Default 1000ms 256MiB

Student Ranking

Student Ranking

In this problem, you are given scores of students for one or more test cases. Your task is to rank the students based on their scores using the competition ranking method. According to this method, if two or more students have the same score, they are assigned the same rank, and the next rank is determined by adding the number of students with higher scores. For example, if the scores are 90, 85, 85, 80, and 70, the corresponding ranks will be 1, 2, 2, 4, and 5 respectively.

Note: Use standard input (stdin) for reading the input and standard output (stdout) for printing the output. Any formulas, if present, must be written in LaTeX format (e.g., a=ba = b).

inputFormat

The input consists of multiple test cases. The first line contains an integer TT representing the number of test cases. For each test case, the first line contains an integer NN representing the number of students. This is followed by NN lines, each containing a student’s name (a string without spaces) and an integer score, separated by a space.

outputFormat

For each test case, output the ranking results of the students sorted in descending order of their scores. Each line should contain the student's name followed by their rank, separated by a space. The outputs for all test cases are concatenated together in the order of input.## sample

1
5
Alice 90
Bob 85
Charlie 85
David 80
Eva 70
Alice 1

Bob 2 Charlie 2 David 4 Eva 5

</p>