eolymp
bolt
Try our new interface for solving problems
Problems

The results of the Olympiad

The results of the Olympiad

During the contest, each participant received a unique identification number - a positive integer. Need to sort a list of participants of the Olympiad on the number of points scored.

Input

The first line contains the number N (1 ≤ N ≤ 1000) - the number of participants. In each following line gives an identification number and dialed the number of points corresponding to the participant. All numbers in the input file does not exceed 105.

Output

The output file output source list in descending order of points. If some participants in the same score, they each want to sort in ascending order of ID number.

Time limit 1 second
Memory limit 64 MiB
Input example #1
3
101 80
305 90
200 14
Output example #1
305 90
101 80
200 14
Input example #2
3
20 80
30 90
25 90
Output example #2
25 90
30 90
20 80
Source Stage II Ukrainian School Olympiad 2011-2012, Berdichev