n=int(eval(input()))

data=[tuple(input().split()+[i+1]) for i in range(n)]

data.sort(key=lambda tup:(tup[0],-int(tup[1])))

for i in data:

	print((i[2]))
#!/usr/bin/env python3

import sys, math, itertools, collections, bisect

input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')

inf = float('inf') ;mod = 10**9+7

mans = inf ;ans = 0 ;count = 0 ;pro = 1



n = int(eval(input()))

data = [input().split()+[i+1] for i in range(n)]

data.sort(key = lambda tup: (tup[0],-int(tup[1])))

for city , k,number in data:

  print(number)
n = int(eval(input()))
data = [tuple(input().split() + [i + 1]) for i in range(n)]
data.sort(key=lambda tup: (tup[0], -int(tup[1])))
for i in data:
    print((i[2]))

#!/usr/bin/env python3
import sys, math, itertools, collections, bisect

input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
inf = float("inf")
mod = 10**9 + 7
mans = inf
ans = 0
count = 0
pro = 1
n = int(eval(input()))
data = [input().split() + [i + 1] for i in range(n)]
data.sort(key=lambda tup: (tup[0], -int(tup[1])))
for city, k, number in data:
    print(number)

+#!/usr/bin/env python3 +import sys, math, itertools, collections, bisect + +input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8") +inf = float("inf") +mod = 10**9 + 7 +mans = inf +ans = 0 +count = 0 +pro = 1 -data = [tuple(input().split() + [i + 1]) for i in range(n)] +data = [input().split() + [i + 1] for i in range(n)] -for i in data: -    print((i[2])) +for city, k, number in data: +    print(number)