The following languages are only available languages for the problems from the contest

Surprise Language Round #8:

- Kotlin 1.3.70

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

B. The Teacher of Physical Education

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard output *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.

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 *name* _{ i} (a non-empty string which consists of uppercase and lowercase Latin letters, the length does not exceed five) and pupil's height *x* _{ i} (130 ≤ *x* _{ i} ≤ 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.

Examples

Input

4

Ivan 150

Igor 215

Dasha 158

Katya 150

Output

Ivan

Katya

Dasha

Igor

Input

2

SASHA 180

SASHA 170

Output

SASHA

SASHA

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/31/2020 04:23:37 (h3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|