n = int(input())
city = []
nums = []
result = []
 
for i in range(n):
  s,p = input().split()
  p = int(p)
  city.append(s)
  nums.append(p)
  result.append([s,p,i+1])
 
for i in sorted(set(city)):
  for j in sorted(set(nums), reverse = True):
    for k in result:
      if k[0] == i and k[1] == j:
        print(k[2]) n = int(input()) n int(input()) int input() input city = [] city [] nums = [] nums [] result = [] result [] for i in range(n):
  s,p = input().split()
  p = int(p)
  city.append(s)
  nums.append(p)
  result.append([s,p,i+1])
  i range(n) range n s,p = input().split() s input().split() ().split () input split p p = int(p) p int(p) int p city.append(s) city.append city append s nums.append(p) nums.append nums append p result.append([s,p,i+1]) result.append result append [s,p,i+1] s p i+1 i 1 for i in sorted(set(city)):
  for j in sorted(set(nums), reverse = True):
    for k in result:
      if k[0] == i and k[1] == j:
        print(k[2]) i sorted(set(city)) sorted set(city) set city for j in sorted(set(nums), reverse = True):
    for k in result:
      if k[0] == i and k[1] == j:
        print(k[2]) j sorted(set(nums), reverse = True) sorted set(nums) set nums reverse = True reverse True for k in result:
      if k[0] == i and k[1] == j:
        print(k[2]) k result if k[0] == i and k[1] == j:
        print(k[2]) k[0] == i and k[1] == j k[0] == i k[0] k 0 i k[1] == j k[1] k 1 j print(k[2]) print k[2] k 2 result = [] [] result s,p = input().split() input().split() s nums = [] [] nums p = input().split() input().split() p n = int(input()) int(input()) n city = [] [] city p = int(p) int(p) p
n = int(input())
city = []
nums = []
result = []
 
for i in range(n):
  s,p = input().split()
  p = int(p)
  city.append(s)
  nums.append(p)
  result.append([s,p,i+1])
 
for i in sorted(set(city)):
  for j in sorted(set(nums), reverse = True):
    for k in result:
      if k[0] == i and k[1] == j:
        print(k[2])