lst = []
for i in range(int(input())):
    S,P = input().split()
    lst.append([S,int(P),i])

sorted_point = sorted(lst,key = lambda x: x[1], reverse = True)
sorted_name = sorted(sorted_point,key = lambda x: x[0], reverse = False) 

for i in sorted_name:
    print(i[2] + 1) lst = [] lst [] for i in range(int(input())):
    S,P = input().split()
    lst.append([S,int(P),i]) i range(int(input())) range int(input()) int input() input S,P = input().split() S input().split() ().split () input split P lst.append([S,int(P),i]) lst.append lst append [S,int(P),i] S int(P) int P i sorted_point = sorted(lst,key = lambda x: x[1], reverse = True) sorted_point sorted(lst,key = lambda x: x[1], reverse = True) sorted lst key = lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse = True reverse True sorted_name = sorted(sorted_point,key = lambda x: x[0], reverse = False) sorted_name sorted(sorted_point,key = lambda x: x[0], reverse = False) sorted sorted_point key = lambda x: x[0] key lambda x: x[0] x[0] x 0 x reverse = False reverse False for i in sorted_name:
    print(i[2] + 1) i sorted_name print(i[2] + 1) print i[2] + 1 i[2] i 2 1 P = input().split() input().split() P sorted_point = sorted(lst,key = lambda x: x[1], reverse = True) sorted(lst,key = lambda x: x[1], reverse = True) sorted_point sorted_name = sorted(sorted_point,key = lambda x: x[0], reverse = False) sorted(sorted_point,key = lambda x: x[0], reverse = False) sorted_name S,P = input().split() input().split() S lst = [] [] lst
lst = []
for i in range(int(input())):
    S,P = input().split()
    lst.append([S,int(P),i])

sorted_point = sorted(lst,key = lambda x: x[1], reverse = True)
sorted_name = sorted(sorted_point,key = lambda x: x[0], reverse = False) 

for i in sorted_name:
    print(i[2] + 1)