n = int(eval(input()))

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

sp = sorted(sp, key=lambda x:(x[0][0], -int(x[0][1])))

for i in range(n):

    print((sp[i][1]))
n = int(eval(input()))

sp = []

for i in range(n):

    sp.append(list(map(str, input().split())))

    sp[i].append(i+1)

sp = sorted(sp, key=lambda x:int(x[1]), reverse=True)

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

for i in range(n):

    print((sp[i][2]))
n = int(eval(input()))
sp = [[input().split(), i + 1] for i in range(n)]
sp = sorted(sp, key=lambda x: (x[0][0], -int(x[0][1])))
for i in range(n):
    print((sp[i][1]))

n = int(eval(input()))
sp = []
for i in range(n):
    sp.append(list(map(str, input().split())))
    sp[i].append(i + 1)
sp = sorted(sp, key=lambda x: int(x[1]), reverse=True)
sp = sorted(sp, key=lambda x: x[0])
for i in range(n):
    print((sp[i][2]))

-sp = [[input().split(), i + 1] for i in range(n)] -sp = sorted(sp, key=lambda x: (x[0][0], -int(x[0][1]))) +sp = [] -    print((sp[i][1])) +    sp.append(list(map(str, input().split()))) +    sp[i].append(i + 1) +sp = sorted(sp, key=lambda x: int(x[1]), reverse=True) +sp = sorted(sp, key=lambda x: x[0]) +for i in range(n): +    print((sp[i][2]))