100 atcoder#ABC128B. [ABC128B] Guidebook

[ABC128B] Guidebook

Score : 200200 points

Problem Statement

You have decided to write a book introducing good restaurants. There are NN restaurants that you want to introduce: Restaurant 11, Restaurant 22, ......, Restaurant NN. Restaurant ii is in city SiS_i, and your assessment score of that restaurant on a 100100-point scale is PiP_i. No two restaurants have the same score.

You want to introduce the restaurants in the following order:

  • The restaurants are arranged in lexicographical order of the names of their cities.
  • If there are multiple restaurants in the same city, they are arranged in descending order of score.

Print the identification numbers of the restaurants in the order they are introduced in the book.

Constraints

  • 1N1001 \leq N \leq 100
  • SS is a string of length between 11 and 1010 (inclusive) consisting of lowercase English letters.
  • 0Pi1000 \leq P_i \leq 100
  • PiP_i is an integer.
  • PiPjP_i \neq P_j (1i<jN)(1 \leq i < j \leq N)

Input

Input is given from Standard Input in the following format:

NN

S1S_1 P1P_1

::

SNS_N PNP_N

Output

Print NN lines. The ii-th line (1iN1 \leq i \leq N) should contain the identification number of the restaurant that is introduced ii-th in the book.

6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
3
4
6
1
5
2

The lexicographical order of the names of the three cities is kazan << khabarovsk << moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,23,4,6,1,5,2.

10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100
10
9
8
7
6
5
4
3
2
1