N = int(eval(input()))

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



L = []

for i in range(N):

  L.append([SP[i][0], int(SP[i][1]), i + 1])



L.sort(key = lambda x: x[1], reverse = True)

L.sort(key = lambda x: x[0])



for i in L:

  print((i[2]))
N = int(eval(input()))

SP = [list(input().split()) + [i + 1] for i in range(N)]



for i in range(N):

  SP[i][1] = -int(SP[i][1])



SP.sort()



for i in range(N):

  print((SP[i][2]))
N = int(eval(input()))
SP = [input().split() for _ in range(N)]
L = []
for i in range(N):
    L.append([SP[i][0], int(SP[i][1]), i + 1])
L.sort(key=lambda x: x[1], reverse=True)
L.sort(key=lambda x: x[0])
for i in L:
    print((i[2]))

N = int(eval(input()))
SP = [list(input().split()) + [i + 1] for i in range(N)]
for i in range(N):
    SP[i][1] = -int(SP[i][1])
SP.sort()
for i in range(N):
    print((SP[i][2]))

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