#C7919. Sort Characters by Strength

    ID: 51843 Type: Default 1000ms 256MiB

Sort Characters by Strength

Sort Characters by Strength

You are given a list of characters with their strength levels. Your task is to sort the characters in non-decreasing order based on their strength level.

If two characters have the same strength level, they should remain in the same relative order as they appeared in the input (i.e. the sort should be stable).

Note: The input is read from stdin and the output should be printed to stdout.

inputFormat

The first line contains an integer n, the number of characters.

The following n lines each contain a string S and an integer L separated by a space, where S is the character's name and L is its strength level.

outputFormat

Print a single line containing the character names sorted in non-decreasing order of their strength levels, separated by spaces.

## sample
5
Alice123 300
bob456 150
Charlie789 200
Dave007 250
eve999 300
bob456 Charlie789 Dave007 Alice123 eve999