The results of the Olympiad#1962

The results of the Olympiad

1 second
64 megabytes
Very easy

During the Olympiad, each participant received a unique identification number, which is a positive integer. You need to sort the list of participants by the number of points they scored.

Input

The first line contains the number (1 \leq N \leq 1000) — the number of participants. Each of the next lines contains the identification number and the number of points earned by the corresponding participant. All numbers in the input do not exceed 10^5.

Output

Print the participants in order of decreasing points. If several participants have the same number of points, sort them by increasing identification number.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading