n = int(input())
list_shop = []
 
for i in range(n):
  t = []
  a, b = input().split()
  t.append(a)
  t.append(b)
  t.append(str(i + 1))
  list_shop.append(t)
 
check = 0
c = []
 
list_shop = sorted(list_shop, key=lambda x: x[0])
 
for i in range(len(list_shop) - 1):
  if(list_shop[i][0] == list_shop[i + 1][0]):
    check = 1
  else:
    check = 0
 
  c.append(list(map(int, list_shop[i][1:3])))
  if(check == 1):
    continue
  else:
    c.sort(key=lambda x:x[0], reverse=True)
    for j in c:
      print(int(j[1]))
    c = []
 
if(check == 1):
  c.append(list(map(int, list_shop[n - 1][1:3])))
  c.sort(key=lambda x:x[0], reverse=True)
  for i in c:
    print(i[1])
else:
  print(int(list_shop[n - 1][2]))