n = int(eval(input()))

dic = [[x for x in input().split()] for i in range(n)]



for i in range(n):

    dic[i][1] = int(dic[i][1])

    dic[i].append(i + 1)



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

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



for i in range(n):

    print((dic[i][2]))
n = int(eval(input()))

dic = []



for i in range(n):

    tmp = input().split()

    dic.append([tmp[0], int(tmp[1]), i + 1])

 

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

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



for i in range(n):

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

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

-dic = [[x for x in input().split()] for i in range(n)] +dic = [] -    dic[i][1] = int(dic[i][1]) -    dic[i].append(i + 1) +    tmp = input().split() +    dic.append([tmp[0], int(tmp[1]), i + 1])