N = int(eval(input()))

A = [[i]+input().split() for i in range(N)]

A = [[A[i][0],A[i][1],int(A[i][2])] for i in range(N)]

A = sorted(A,key=lambda x:x[2],reverse=True)

A = sorted(A,key=lambda x:x[1])

for i in range(N):

    j,_,_ = A[i]

    print((j+1))
N=int(eval(input()))

A = []

for i in range(N):

    s,p = input().split()

    p = int(p)

    A.append((s,p,i+1))

A = sorted(A,key=lambda x:x[1],reverse=True)

A = sorted(A,key=lambda x:x[0])

for i in range(N):

    s,p,k = A[i]

    print(k)
N = int(eval(input()))
A = [[i] + input().split() for i in range(N)]
A = [[A[i][0], A[i][1], int(A[i][2])] for i in range(N)]
A = sorted(A, key=lambda x: x[2], reverse=True)
A = sorted(A, key=lambda x: x[1])
for i in range(N):
    j, _, _ = A[i]
    print((j + 1))

N = int(eval(input()))
A = []
for i in range(N):
    s, p = input().split()
    p = int(p)
    A.append((s, p, i + 1))
A = sorted(A, key=lambda x: x[1], reverse=True)
A = sorted(A, key=lambda x: x[0])
for i in range(N):
    s, p, k = A[i]
    print(k)

-A = [[i] + input().split() for i in range(N)] -A = [[A[i][0], A[i][1], int(A[i][2])] for i in range(N)] -A = sorted(A, key=lambda x: x[2], reverse=True) -A = sorted(A, key=lambda x: x[1]) +A = [] -    j, _, _ = A[i] -    print((j + 1)) +    s, p = input().split() +    p = int(p) +    A.append((s, p, i + 1)) +A = sorted(A, key=lambda x: x[1], reverse=True) +A = sorted(A, key=lambda x: x[0]) +for i in range(N): +    s, p, k = A[i] +    print(k)