#B

N = int(eval(input()))

S = [""] * N

P = [0] * N

P2 = [""] * N

NUM = [0] * N

for i in range(0, N):

    S[i], P2[i] = list(map(str, input().split()))

    P[i] = int(P2[i])

    NUM[i] = i + 1

for i in range(0, N):

    for j in range(1, N):

        if S[j] < S[j-1]:

            S[j-1], S[j] = S[j], S[j-1]

            P[j-1], P[j] = P[j], P[j-1]

            NUM[j-1], NUM[j] = NUM[j], NUM[j-1]

        if S[j] == S[j-1]:

            if P[j] > P[j-1]:

                S[j-1], S[j] = S[j], S[j-1]

                P[j-1], P[j] = P[j], P[j-1]

                NUM[j-1], NUM[j] = NUM[j], NUM[j-1]

for i in range(0,N):

    print((NUM[i]))
from operator import itemgetter

N = int(eval(input()))

S = [""] * N

P = [0] * N

P2 = [""] * N

NUM = [0] * N

lst = [""] * N

for i in range(0, N):

    S[i], P2[i] = list(map(str, input().split()))

    P[i] = int(P2[i])

    NUM[i] = i + 1

    lst[i] = (S[i], P[i], NUM[i])

sorted1 = sorted(lst, key=itemgetter(1), reverse=True)

sorted2 = sorted(sorted1, key=itemgetter(0))

for i in range(0,N):

     print((sorted2[i][2]))
# B
N = int(eval(input()))
S = [""] * N
P = [0] * N
P2 = [""] * N
NUM = [0] * N
for i in range(0, N):
    S[i], P2[i] = list(map(str, input().split()))
    P[i] = int(P2[i])
    NUM[i] = i + 1
for i in range(0, N):
    for j in range(1, N):
        if S[j] < S[j - 1]:
            S[j - 1], S[j] = S[j], S[j - 1]
            P[j - 1], P[j] = P[j], P[j - 1]
            NUM[j - 1], NUM[j] = NUM[j], NUM[j - 1]
        if S[j] == S[j - 1]:
            if P[j] > P[j - 1]:
                S[j - 1], S[j] = S[j], S[j - 1]
                P[j - 1], P[j] = P[j], P[j - 1]
                NUM[j - 1], NUM[j] = NUM[j], NUM[j - 1]
for i in range(0, N):
    print((NUM[i]))

from operator import itemgetter

N = int(eval(input()))
S = [""] * N
P = [0] * N
P2 = [""] * N
NUM = [0] * N
lst = [""] * N
for i in range(0, N):
    S[i], P2[i] = list(map(str, input().split()))
    P[i] = int(P2[i])
    NUM[i] = i + 1
    lst[i] = (S[i], P[i], NUM[i])
sorted1 = sorted(lst, key=itemgetter(1), reverse=True)
sorted2 = sorted(sorted1, key=itemgetter(0))
for i in range(0, N):
    print((sorted2[i][2]))

-# B +from operator import itemgetter + +lst = [""] * N +    lst[i] = (S[i], P[i], NUM[i]) +sorted1 = sorted(lst, key=itemgetter(1), reverse=True) +sorted2 = sorted(sorted1, key=itemgetter(0)) -    for j in range(1, N): -        if S[j] < S[j - 1]: -            S[j - 1], S[j] = S[j], S[j - 1] -            P[j - 1], P[j] = P[j], P[j - 1] -            NUM[j - 1], NUM[j] = NUM[j], NUM[j - 1] -        if S[j] == S[j - 1]: -            if P[j] > P[j - 1]: -                S[j - 1], S[j] = S[j], S[j - 1] -                P[j - 1], P[j] = P[j], P[j - 1] -                NUM[j - 1], NUM[j] = NUM[j], NUM[j - 1] -for i in range(0, N): -    print((NUM[i])) +    print((sorted2[i][2]))