N = int(input())

restaurants = {}
for i in range(1, N+1):
    s, p = input().split()
    restaurants[i] = (s, int(p) * -1)

key = lambda x: (x[1][0], x[1][1])
restaurants_sorted = sorted(restaurants.items(), key=key)

for k in restaurants_sorted:
    print(k[0]) N = int(input()) N int(input()) int input() input restaurants = {} restaurants {} for i in range(1, N+1):
    s, p = input().split()
    restaurants[i] = (s, int(p) * -1) i range(1, N+1) range 1 N+1 N 1 s, p = input().split() s input().split() ().split () input split p restaurants[i] = (s, int(p) * -1) restaurants[i] restaurants i (s, int(p) * -1) s int(p) * -1 int(p) int p -1 key = lambda x: (x[1][0], x[1][1]) key lambda x: (x[1][0], x[1][1]) (x[1][0], x[1][1]) x[1][0] [1] x 1 0 x[1][1] [1] x 1 1 x restaurants_sorted = sorted(restaurants.items(), key=key) restaurants_sorted sorted(restaurants.items(), key=key) sorted restaurants.items() restaurants.items restaurants items key=key key key for k in restaurants_sorted:
    print(k[0]) k restaurants_sorted print(k[0]) print k[0] k 0 key = lambda x: (x[1][0], x[1][1]) lambda x: (x[1][0], x[1][1]) key restaurants = {} {} restaurants s, p = input().split() input().split() s restaurants_sorted = sorted(restaurants.items(), key=key) sorted(restaurants.items(), key=key) restaurants_sorted N = int(input()) int(input()) N p = input().split() input().split() p
N = int(input())

restaurants = {}
for i in range(1, N+1):
    s, p = input().split()
    restaurants[i] = (s, int(p) * -1)

key = lambda x: (x[1][0], x[1][1])
restaurants_sorted = sorted(restaurants.items(), key=key)

for k in restaurants_sorted:
    print(k[0])