#t551. 成绩排序

成绩排序

Sorting Grades

Problem Description

Given the grade list of a certain course in a class, sort and output the list by grade from high to low. If two students have the same grade, the one with the lexicographically smaller name comes first.

Input Format

The first line is an integer nn with 0<n<200 < n < 20, the number of students in the class.

The following nn lines each contain a student's name and his/her grade, separated by a single space. The name contains only letters and has length at most 2020. The grade is a non-negative integer not greater than 100100.

Output Format

Sort the grade list in descending order of grades and output it. Each line contains the name and the grade, separated by a single space.

Sample Input

4
Kitty 80
Hanmeimei 90
Joey 92
Tim 28

Sample Output

Joey 92
Hanmeimei 90
Kitty 80
Tim 28

Sample Explanation

There are 44 students: Kitty scored 8080, Hanmeimei 9090, Joey 9292, Tim 2828. After sorting by grade from high to low, the order is Joey (9292), Hanmeimei (9090), Kitty (8080), Tim (2828). Since there are no equal grades, name lexicographic order is not needed, so the output is exactly the four lines above.

Constraints

0<n<200 < n < 20; name length at most 2020; grade is a non-negative integer not greater than 100100.