n=int(input())
a=[]
for i in range(n):
  a.append(list(input().split()))
for i in range(0,n):
  a[i].append(i+1)
for i in range(0,len(a)):
  a[i][1]=int(a[i][1])

a.sort(key=lambda x:(x[0],-x[1]),reverse = False)
for i in range(0,n):
  print(a[i][2])

