Limits 1s, 512 MB

My sister's best friend - Anusha is like a sister. Her family and my family are like family. We give our qurbani together, yes that close...

Ok wait! Did that ring any bell?

Yes these lines were taken from some famous writer Ms. Khan's book বান্ধobi. The book is so good that after reading two or three pages of it I now have a brain full of knowledge and a mind full of enthusiasm.

In the last few days the problem setter committee called me several times and asked me to prepare a problem for the upcoming contest. But you know I am not as good as them. My brain usually struggles to produce ideas for problems. But thanks to this masterpiece book I now have an idea for a problem.

Here is another of Ms. Khan's line from her book:

I honestly love her and consider her as my 13th favorite human being alive.

Every time I read this line it gives me goosebumps. Look how she is ordering the human beings she likes. Have you ever tried this? I tried and failed miserably. Do you have some time to help me?

In this problem you will be given the name of n friends of mine and a point for each of them which defines how much I like them. Let’s call this point RBpoint. You have to sort all my friends' names in decreasing order of RBpoint.

Input

The first line of the input will contain the value of n (2 ≤ n ≤ 26). The next n lines will contain one upper case English alphabet which is my friend's name and an integer number which is the RBpoint for that friend. All RBpoints will be between 1 and 100. It is guaranteed that all friends' names and all RBpoints will be unique.

Output

Print the n friends' names sorted by their RBpoint, each separated by a space.

Sample

InputOutput
3
A 1
B 3
C 2
B C A

Submit

Login to submit.

Statistics

87% Solution Ratio
Mehedi_MithunEarliest, Apr '19
Mehedi_MithunFastest, 0.0s
touhidurrrLightest, 0 B
Nusab19Shortest, 96B
Toph uses cookies. By continuing you agree to our Cookie Policy.