codeforces#P683B. The Teacher of Physical Education
The Teacher of Physical Education
Description
n pupils came to Physical Education lesson. We know the name and the height of each pupil.
Your task is to help the teacher of Physical Education to line up all pupils in non-decreasing order of their heights.
The first line contains the positive integer n (1 ≤ n ≤ 5000) — the number of pupils.
The next n lines contain the pupils' description. In the i-th line there is pupil's name namei (a non-empty string which consists of uppercase and lowercase Latin letters, the length does not exceed five) and pupil's height xi (130 ≤ xi ≤ 215). Some pupils can have the same name. Uppercase and lowercase letters of the alphabet should be considered different.
Print n lines — pupils' names in the non-decreasing order of their heights. Each line must contain exactly one name.
If there are several answers, print any of them. Uppercase and lowercase letters of the alphabet should be considered different.
Input
The first line contains the positive integer n (1 ≤ n ≤ 5000) — the number of pupils.
The next n lines contain the pupils' description. In the i-th line there is pupil's name namei (a non-empty string which consists of uppercase and lowercase Latin letters, the length does not exceed five) and pupil's height xi (130 ≤ xi ≤ 215). Some pupils can have the same name. Uppercase and lowercase letters of the alphabet should be considered different.
Output
Print n lines — pupils' names in the non-decreasing order of their heights. Each line must contain exactly one name.
If there are several answers, print any of them. Uppercase and lowercase letters of the alphabet should be considered different.
Samples
4
Ivan 150
Igor 215
Dasha 158
Katya 150
Ivan
Katya
Dasha
Igor
2
SASHA 180
SASHA 170
SASHA
SASHA