from operator import itemgetter
n = int(input())
dic = {}
for i in range(1, n + 1):
  s, p = input().split()
  p = int(p)
  dic.setdefault(s, [])
  dic[s].append((i, p))
cities = sorted(list(dic.keys()))
for c in cities:
  dic[c].sort(key=itemgetter(1), reverse=True)
  for i in dic[c]:
    print(i[0]) from operator import itemgetter n = int(input()) n int(input()) int input() input dic = {} dic {} for i in range(1, n + 1):
  s, p = input().split()
  p = int(p)
  dic.setdefault(s, [])
  dic[s].append((i, p)) i range(1, n + 1) range 1 n + 1 n 1 s, p = input().split() s input().split() ().split () input split p p = int(p) p int(p) int p dic.setdefault(s, []) dic.setdefault dic setdefault s [] dic[s].append((i, p)) [s].append [s] dic s append (i, p) i p cities = sorted(list(dic.keys())) cities sorted(list(dic.keys())) sorted list(dic.keys()) list dic.keys() dic.keys dic keys for c in cities:
  dic[c].sort(key=itemgetter(1), reverse=True)
  for i in dic[c]:
    print(i[0]) c cities dic[c].sort(key=itemgetter(1), reverse=True) [c].sort [c] dic c sort key=itemgetter(1) key itemgetter(1) itemgetter 1 reverse=True reverse True for i in dic[c]:
    print(i[0]) i dic[c] dic c print(i[0]) print i[0] i 0 p = input().split() input().split() p n = int(input()) int(input()) n dic = {} {} dic p = int(p) int(p) p cities = sorted(list(dic.keys())) sorted(list(dic.keys())) cities s, p = input().split() input().split() s
from operator import itemgetter
n = int(input())
dic = {}
for i in range(1, n + 1):
  s, p = input().split()
  p = int(p)
  dic.setdefault(s, [])
  dic[s].append((i, p))
cities = sorted(list(dic.keys()))
for c in cities:
  dic[c].sort(key=itemgetter(1), reverse=True)
  for i in dic[c]:
    print(i[0])