N = int(input())
data = []
ans = []
for i in range(1, N+1):
  city, score = input().split()
  score = int(score)
  data.append([city, score, i])
city_list = [x[0] for x in data]
score_list = [x[1] for x in data]
num_list = [x[2] for x in data]
city_unique = sorted(set(city_list))

for city_u in city_unique:
  city_index = [i for i, x in enumerate(city_list) if x == city_u]
  for score in sorted([score_list[x] for x in city_index], reverse=True):
    print(num_list[score_list.index(score)]) N = int(input()) N int(input()) int input() input data = [] data [] ans = [] ans [] for i in range(1, N+1):
  city, score = input().split()
  score = int(score)
  data.append([city, score, i]) i range(1, N+1) range 1 N+1 N 1 city, score = input().split() city input().split() ().split () input split score score = int(score) score int(score) int score data.append([city, score, i]) data.append data append [city, score, i] city score i x[0] for x in data for x in data x data for x in data x[0] x 0 city_list = [x[0] for x in data] city_list [x[0] for x in data] x[1] for x in data for x in data x data for x in data x[1] x 1 score_list = [x[1] for x in data] score_list [x[1] for x in data] x[2] for x in data for x in data x data for x in data x[2] x 2 num_list = [x[2] for x in data] num_list [x[2] for x in data] city_unique = sorted(set(city_list)) city_unique sorted(set(city_list)) sorted set(city_list) set city_list for city_u in city_unique:
  city_index = [i for i, x in enumerate(city_list) if x == city_u]
  for score in sorted([score_list[x] for x in city_index], reverse=True):
    print(num_list[score_list.index(score)]) city_u city_unique i for i, x in enumerate(city_list) if x == city_u for i, x in enumerate(city_list) if x == city_u i x enumerate(city_list) enumerate city_list x == city_u x city_u if x == city_u i city_index = [i for i, x in enumerate(city_list) if x == city_u] city_index [i for i, x in enumerate(city_list) if x == city_u] for score in sorted([score_list[x] for x in city_index], reverse=True):
    print(num_list[score_list.index(score)]) score sorted([score_list[x] for x in city_index], reverse=True) sorted [score_list[x] for x in city_index] reverse=True reverse True print(num_list[score_list.index(score)]) print num_list[score_list.index(score)] num_list score_list.index(score) score_list.index score_list index score N = int(input()) int(input()) N city_index = [i for i, x in enumerate(city_list) if x == city_u] [i for i, x in enumerate(city_list) if x == city_u] city_index city_unique = sorted(set(city_list)) sorted(set(city_list)) city_unique city, score = input().split() input().split() city city_list = [x[0] for x in data] [x[0] for x in data] city_list score = input().split() input().split() score data = [] [] data ans = [] [] ans score = int(score) int(score) score score_list = [x[1] for x in data] [x[1] for x in data] score_list num_list = [x[2] for x in data] [x[2] for x in data] num_list
N = int(input())
data = []
ans = []
for i in range(1, N+1):
  city, score = input().split()
  score = int(score)
  data.append([city, score, i])
city_list = [x[0] for x in data]
score_list = [x[1] for x in data]
num_list = [x[2] for x in data]
city_unique = sorted(set(city_list))

for city_u in city_unique:
  city_index = [i for i, x in enumerate(city_list) if x == city_u]
  for score in sorted([score_list[x] for x in city_index], reverse=True):
    print(num_list[score_list.index(score)])