N = int(eval(input()))

Book = [0] * N

for i in range(N):

    s,q = input().split()

    p = int(q)

    Book[i] = (s, 100-p, i)



Book.sort()



for i in range(N):

    print((Book[i][2]+1))





N = int(eval(input()))

L = []

for _ in range(N):

    s, p = input().split()

    p = int(p)

    L.append((s, 100 - p, _))



L.sort()

for _ in range(N):

    print((L[_][2]+1))



N = int(eval(input()))
Book = [0] * N
for i in range(N):
    s, q = input().split()
    p = int(q)
    Book[i] = (s, 100 - p, i)
Book.sort()
for i in range(N):
    print((Book[i][2] + 1))

N = int(eval(input()))
L = []
for _ in range(N):
    s, p = input().split()
    p = int(p)
    L.append((s, 100 - p, _))
L.sort()
for _ in range(N):
    print((L[_][2] + 1))

-Book = [0] * N -for i in range(N): -    s, q = input().split() -    p = int(q) -    Book[i] = (s, 100 - p, i) -Book.sort() -for i in range(N): -    print((Book[i][2] + 1)) +L = [] +for _ in range(N): +    s, p = input().split() +    p = int(p) +    L.append((s, 100 - p, _)) +L.sort() +for _ in range(N): +    print((L[_][2] + 1))