from collections import defaultdict

import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)



n = int(eval(input()))

SP = [[x for x in input().split()] for _ in range(n)]

ans_list = defaultdict(list)

for i, sp in enumerate(SP):

    ans_list[sp[1]] = i



li = sorted(SP, key=lambda x: -int(x[1]))

li = sorted(li, key=lambda x: x[0])

#print(li)

#print(ans_list)

for x in li:

    print((ans_list[x[1]]+1))



N = int(eval(input()))

SP = []

for i in range(N):

  s, p = list(input().split())

  SP.append([s, int(p), i+1])

SP.sort(key=lambda SP:(SP[0], -SP[1]))

for x in SP:

  print((x[2]))
from collections import defaultdict
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n = int(eval(input()))
SP = [[x for x in input().split()] for _ in range(n)]
ans_list = defaultdict(list)
for i, sp in enumerate(SP):
    ans_list[sp[1]] = i
li = sorted(SP, key=lambda x: -int(x[1]))
li = sorted(li, key=lambda x: x[0])
# print(li)
# print(ans_list)
for x in li:
    print((ans_list[x[1]] + 1))

N = int(eval(input()))
SP = []
for i in range(N):
    s, p = list(input().split())
    SP.append([s, int(p), i + 1])
SP.sort(key=lambda SP: (SP[0], -SP[1]))
for x in SP:
    print((x[2]))

-from collections import defaultdict -import sys - -input = sys.stdin.readline -sys.setrecursionlimit(10**7) -n = int(eval(input())) -SP = [[x for x in input().split()] for _ in range(n)] -ans_list = defaultdict(list) -for i, sp in enumerate(SP): -    ans_list[sp[1]] = i -li = sorted(SP, key=lambda x: -int(x[1])) -li = sorted(li, key=lambda x: x[0]) -# print(li) -# print(ans_list) -for x in li: -    print((ans_list[x[1]] + 1)) +N = int(eval(input())) +SP = [] +for i in range(N): +    s, p = list(input().split()) +    SP.append([s, int(p), i + 1]) +SP.sort(key=lambda SP: (SP[0], -SP[1])) +for x in SP: +    print((x[2]))