N = int(input())
List = []
for i in range(N):
  List.append(list(map(str, input().split())))
Names = []
Points = []
for i in range(N):
  Names.append(List[i][0])
  Points.append(int(List[i][1]))
slName = set(Names)
NewName = list(slName)
NewName.sort()
Points.sort(reverse = True)
for i in range(len(NewName)):
  for j in range(len(Points)):
    for k in range(N):
      if List[k][0] == NewName[i] and int(List[k][1]) == Points[j]:
        print(k+1)
      else:
        pass N = int(input()) N int(input()) int input() input List = [] List [] for i in range(N):
  List.append(list(map(str, input().split()))) i range(N) range N List.append(list(map(str, input().split()))) List.append List append list(map(str, input().split())) list map(str, input().split()) map str input().split() ().split () input split Names = [] Names [] Points = [] Points [] for i in range(N):
  Names.append(List[i][0])
  Points.append(int(List[i][1])) i range(N) range N Names.append(List[i][0]) Names.append Names append List[i][0] [i] List i 0 Points.append(int(List[i][1])) Points.append Points append int(List[i][1]) int List[i][1] [i] List i 1 slName = set(Names) slName set(Names) set Names NewName = list(slName) NewName list(slName) list slName NewName.sort() NewName.sort NewName sort Points.sort(reverse = True) Points.sort Points sort reverse = True reverse True for i in range(len(NewName)):
  for j in range(len(Points)):
    for k in range(N):
      if List[k][0] == NewName[i] and int(List[k][1]) == Points[j]:
        print(k+1)
      else:
        pass i range(len(NewName)) range len(NewName) len NewName for j in range(len(Points)):
    for k in range(N):
      if List[k][0] == NewName[i] and int(List[k][1]) == Points[j]:
        print(k+1)
      else:
        pass j range(len(Points)) range len(Points) len Points for k in range(N):
      if List[k][0] == NewName[i] and int(List[k][1]) == Points[j]:
        print(k+1)
      else:
        pass k range(N) range N if List[k][0] == NewName[i] and int(List[k][1]) == Points[j]:
        print(k+1)
      else:
        pass List[k][0] == NewName[i] and int(List[k][1]) == Points[j] List[k][0] == NewName[i] List[k][0] [k] List k 0 NewName[i] NewName i int(List[k][1]) == Points[j] int(List[k][1]) int List[k][1] [k] List k 1 Points[j] Points j print(k+1) print k+1 k 1 N = int(input()) int(input()) N List = [] [] List slName = set(Names) set(Names) slName NewName = list(slName) list(slName) NewName Points = [] [] Points Names = [] [] Names
N = int(input())
List = []
for i in range(N):
  List.append(list(map(str, input().split())))
Names = []
Points = []
for i in range(N):
  Names.append(List[i][0])
  Points.append(int(List[i][1]))
slName = set(Names)
NewName = list(slName)
NewName.sort()
Points.sort(reverse = True)
for i in range(len(NewName)):
  for j in range(len(Points)):
    for k in range(N):
      if List[k][0] == NewName[i] and int(List[k][1]) == Points[j]:
        print(k+1)
      else:
        pass