atcoder#ABC304A. [ABC304A] First Player

[ABC304A] First Player

Score : 100100 points

Problem Statement

There are NN people numbered 1,2,,N1, 2, \ldots, N, sitting in this clockwise order around a round table. In particular, person 11 is sitting next to person NN in the clockwise direction.

For each i=1,2,,Ni = 1, 2, \ldots, N, person ii has a name SiS_i and an age AiA_i. Here, no two people have the same name or the same age.

Starting from the youngest person, print the names of all NN people in the order of their seating positions in clockwise order.

Constraints

  • 2N1002 \leq N \leq 100
  • NN is an integer.
  • SiS_i is a string of length between 11 and 1010, consisting of lowercase English letters.
  • ij    SiSji \neq j \implies S_i \neq S_j
  • 0Ai1090 \leq A_i \leq 10^9
  • AiA_i is an integer.
  • ij    AiAji \neq j \implies A_i \neq A_j

Input

The input is given from Standard Input in the following format:

NN

S1S_1 A1A_1

S2S_2 A2A_2

\vdots

SNS_N ANA_N

Output

Print NN lines. For each i=1,2,,Ni = 1, 2, \ldots, N, the ii-th line should contain the name of the person sitting in the ii-th position clockwise from the youngest person.

5
alice 31
bob 41
carol 5
dave 92
ellen 65
carol
dave
ellen
alice
bob

The youngest person is person 33. Therefore, starting from person 33, print the names in the clockwise order of their seating positions: person 33, person 44, person 55, person 11, and person 22.

2
takahashi 1000000000
aoki 999999999
aoki
takahashi