N=int(input())
d={}
k=[]
for x in range(N):
  S,P=input().split()
  if S not in k:
    k.append(S)
    d[S]=[]
  d[S].append([int(P),x+1])
k.sort()
for y in k:
  d[y].sort(reverse=True)
  for z in range(len(d[y])):
    print(d[y][z][1]) N=int(input()) N int(input()) int input() input d={} d {} k=[] k [] for x in range(N):
  S,P=input().split()
  if S not in k:
    k.append(S)
    d[S]=[]
  d[S].append([int(P),x+1]) x range(N) range N S,P=input().split() S input().split() ().split () input split P if S not in k:
    k.append(S)
    d[S]=[]
   S not in k S k k.append(S) k.append k append S d[S]=[] d[S] d S [] d[S].append([int(P),x+1]) [S].append [S] d S append [int(P),x+1] int(P) int P x+1 x 1 k.sort() k.sort k sort for y in k:
  d[y].sort(reverse=True)
  for z in range(len(d[y])):
    print(d[y][z][1]) y k d[y].sort(reverse=True) [y].sort [y] d y sort reverse=True reverse True for z in range(len(d[y])):
    print(d[y][z][1]) z range(len(d[y])) range len(d[y]) len d[y] d y print(d[y][z][1]) print d[y][z][1] [z] [y] d y z 1 S,P=input().split() input().split() S d={} {} d P=input().split() input().split() P k=[] [] k N=int(input()) int(input()) N
N=int(input())
d={}
k=[]
for x in range(N):
  S,P=input().split()
  if S not in k:
    k.append(S)
    d[S]=[]
  d[S].append([int(P),x+1])
k.sort()
for y in k:
  d[y].sort(reverse=True)
  for z in range(len(d[y])):
    print(d[y][z][1])