n=int(input())
l=[]
for i in range(n):
  s,p=[x for x in input().rstrip().split()]
  l.append([s,int(p),i+1])
l.sort(key=lambda x:x[1],reverse=True)
l.sort(key=lambda x:x[0])

for s,p,i in l:
  print(i) 
