N = int(eval(input()))

S = [None]*N

P = [None]*N

I = [None]*N

for i in range(N):

    tmp = input().split()

    S[i] = tmp[0]

    P[i] = int(tmp[1])

    I[i] = i+1





def less(a, b):

    if a[0] == b[0]:

        if a[1] == b[1]:

            return a[2] < b[2]

        return a[1] > b[1]

    return a[0] < b[0]





for i in range(N):

    for j in range(i+1, N):

        if not less([S[i], P[i], I[i]], [S[j], P[j], I[j]]):

            S[i], S[j] = S[j], S[i]

            P[i], P[j] = P[j], P[i]

            I[i], I[j] = I[j], I[i]



for i in range(N):

    print((I[i]))

N = int(eval(input()))

T = [None]*N

for i in range(N):

    tmp = input().split()

    T[i] = (tmp[0], -int(tmp[1]), i+1)



T.sort()

for t in T:

    print((t[2]))

N = int(eval(input()))
S = [None] * N
P = [None] * N
I = [None] * N
for i in range(N):
    tmp = input().split()
    S[i] = tmp[0]
    P[i] = int(tmp[1])
    I[i] = i + 1


def less(a, b):
    if a[0] == b[0]:
        if a[1] == b[1]:
            return a[2] < b[2]
        return a[1] > b[1]
    return a[0] < b[0]


for i in range(N):
    for j in range(i + 1, N):
        if not less([S[i], P[i], I[i]], [S[j], P[j], I[j]]):
            S[i], S[j] = S[j], S[i]
            P[i], P[j] = P[j], P[i]
            I[i], I[j] = I[j], I[i]
for i in range(N):
    print((I[i]))

N = int(eval(input()))
T = [None] * N
for i in range(N):
    tmp = input().split()
    T[i] = (tmp[0], -int(tmp[1]), i + 1)
T.sort()
for t in T:
    print((t[2]))

-S = [None] * N -P = [None] * N -I = [None] * N +T = [None] * N -    S[i] = tmp[0] -    P[i] = int(tmp[1]) -    I[i] = i + 1 - - -def less(a, b): -    if a[0] == b[0]: -        if a[1] == b[1]: -            return a[2] < b[2] -        return a[1] > b[1] -    return a[0] < b[0] - - -for i in range(N): -    for j in range(i + 1, N): -        if not less([S[i], P[i], I[i]], [S[j], P[j], I[j]]): -            S[i], S[j] = S[j], S[i] -            P[i], P[j] = P[j], P[i] -            I[i], I[j] = I[j], I[i] -for i in range(N): -    print((I[i])) +    T[i] = (tmp[0], -int(tmp[1]), i + 1) +T.sort() +for t in T: +    print((t[2]))