N = int(input())

restaurants = []
for i in range(N):
    S, P = input().split()
    P = int(P)

    restaurants.append([S,-P, i+1])

restaurants.sort()

for x in restaurants:
    print(x[2])
 N = int(input()) N int(input()) int input() input restaurants = [] restaurants [] for i in range(N):
    S, P = input().split()
    P = int(P)

    restaurants.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 restaurants.append([S,-P, i+1]) restaurants.append restaurants append [S,-P, i+1] S -P P i+1 i 1 restaurants.sort() restaurants.sort restaurants sort for x in restaurants:
    print(x[2]) x restaurants print(x[2]) print x[2] x 2 restaurants = [] [] restaurants P = int(P) int(P) P S, P = input().split() input().split() S P = input().split() input().split() P N = int(input()) int(input()) N
N = int(input())

restaurants = []
for i in range(N):
    S, P = input().split()
    P = int(P)

    restaurants.append([S,-P, i+1])

restaurants.sort()

for x in restaurants:
    print(x[2])

