#P415. 练71.1成绩排序

练71.1成绩排序

Description

Given a grade report for a course in a class, please sort and output the report by grades from highest to lowest. If there are students with the same grade, sort them by name in lexicographical order.

Input Format

The first line contains nn (0<n<200 < n < 20), indicating the number of students in the class;
The next nn lines each contain a student's name and grade, separated by a single space. The name contains only letters and has length not exceeding 2020, and the grade is a non-negative integer not exceeding 100100.

Output Format

Sort the grade report by grades from highest to lowest and output it. Each line contains the name and grade, separated by a space.

Sample

4
Kitty 80
Hanmeimei 90
Joey 92
Tim 28
Joey 92
Hanmeimei 90
Kitty 80
Tim 28