i = int(input())
score = [input().split() for s in range(i)]
s_list = sorted(score)

for i in range(len(s_list)):
  for j in reversed(range(i+1, len(s_list))):
    if s_list[j-1][0] == s_list[j][0] and int(s_list[j-1][1]) < int(s_list[j][1]):
      s_list[j-1], s_list[j] = s_list[j], s_list[j-1]

for s in s_list:
  for index,sc in enumerate(score):
    if s == sc:
      print(index+1) i = int(input()) i int(input()) int input() input input().split() for s in range(i) for s in range(i) s range(i) range i for s in range(i) input().split() ().split () input split score = [input().split() for s in range(i)] score [input().split() for s in range(i)] s_list = sorted(score) s_list sorted(score) sorted score for i in range(len(s_list)):
  for j in reversed(range(i+1, len(s_list))):
    if s_list[j-1][0] == s_list[j][0] and int(s_list[j-1][1]) < int(s_list[j][1]):
      s_list[j-1], s_list[j] = s_list[j], s_list[j-1] i range(len(s_list)) range len(s_list) len s_list for j in reversed(range(i+1, len(s_list))):
    if s_list[j-1][0] == s_list[j][0] and int(s_list[j-1][1]) < int(s_list[j][1]):
      s_list[j-1], s_list[j] = s_list[j], s_list[j-1] j reversed(range(i+1, len(s_list))) reversed range(i+1, len(s_list)) range i+1 i 1 len(s_list) len s_list if s_list[j-1][0] == s_list[j][0] and int(s_list[j-1][1]) < int(s_list[j][1]):
      s_list[j-1], s_list[j] = s_list[j], s_list[j-1] s_list[j-1][0] == s_list[j][0] and int(s_list[j-1][1]) < int(s_list[j][1]) s_list[j-1][0] == s_list[j][0] s_list[j-1][0] [j-1] s_list j-1 j 1 0 s_list[j][0] [j] s_list j 0 int(s_list[j-1][1]) < int(s_list[j][1]) int(s_list[j-1][1]) int s_list[j-1][1] [j-1] s_list j-1 j 1 1 int(s_list[j][1]) int s_list[j][1] [j] s_list j 1 s_list[j-1], s_list[j] = s_list[j], s_list[j-1] s_list[j-1] s_list j-1 j 1 s_list[j] s_list j s_list[j] s_list j s_list[j-1] s_list j-1 j 1 for s in s_list:
  for index,sc in enumerate(score):
    if s == sc:
      print(index+1) s s_list for index,sc in enumerate(score):
    if s == sc:
      print(index+1) index sc enumerate(score) enumerate score if s == sc:
      print(index+1) s == sc s sc print(index+1) print index+1 index 1 s_list = sorted(score) sorted(score) s_list i = int(input()) int(input()) i score = [input().split() for s in range(i)] [input().split() for s in range(i)] score
i = int(input())
score = [input().split() for s in range(i)]
s_list = sorted(score)

for i in range(len(s_list)):
  for j in reversed(range(i+1, len(s_list))):
    if s_list[j-1][0] == s_list[j][0] and int(s_list[j-1][1]) < int(s_list[j][1]):
      s_list[j-1], s_list[j] = s_list[j], s_list[j-1]

for s in s_list:
  for index,sc in enumerate(score):
    if s == sc:
      print(index+1)