import numpy as np

N = [int(i) for i in input().split()][0]

ls = []
for i in range(N):
  a,b = [i for i in input().split()]
  tmp = [str(a),int(b)]
  ls.append(tmp)

new_ls = sorted(ls, key=lambda x:x[1], reverse=True)
new_ls = sorted(new_ls, key=lambda x:x[0])

for next,l in enumerate(new_ls):
  for i,tmp in enumerate(ls):
    if l[0]==tmp[0] and l[1]==tmp[1]:
      print(i+1)
      continue