N = int(eval(input()))

MAIN = []

for i in range(N):

    S,P = list(map(str,input().split()))

    MAIN.append([i+1,S,int(P)])



def swap(i,j):

    x = MAIN[i]

    MAIN[i] = MAIN[j]

    MAIN[j] = x



update = True

while update == True:

    update = False

    for i in range(1,N):

        if MAIN[i][1] > MAIN[i-1][1]:

            continue

        elif MAIN[i][1] == MAIN[i-1][1]:

            if MAIN[i][2] > MAIN[i-1][2]:

                swap(i,i-1)

                update = True

        else:

            swap(i,i-1)

            update = True





for m in MAIN:

    print((m[0]))
N = int(eval(input()))

MAIN = []

for i in range(N):

    S,P = list(map(str,input().split()))

    MAIN.append([S,-int(P)])



ans = sorted(MAIN)

for m in ans:

    print((MAIN.index(m) + 1))
N = int(eval(input()))
MAIN = []
for i in range(N):
    S, P = list(map(str, input().split()))
    MAIN.append([i + 1, S, int(P)])


def swap(i, j):
    x = MAIN[i]
    MAIN[i] = MAIN[j]
    MAIN[j] = x


update = True
while update == True:
    update = False
    for i in range(1, N):
        if MAIN[i][1] > MAIN[i - 1][1]:
            continue
        elif MAIN[i][1] == MAIN[i - 1][1]:
            if MAIN[i][2] > MAIN[i - 1][2]:
                swap(i, i - 1)
                update = True
        else:
            swap(i, i - 1)
            update = True
for m in MAIN:
    print((m[0]))

N = int(eval(input()))
MAIN = []
for i in range(N):
    S, P = list(map(str, input().split()))
    MAIN.append([S, -int(P)])
ans = sorted(MAIN)
for m in ans:
    print((MAIN.index(m) + 1))

-    MAIN.append([i + 1, S, int(P)]) - - -def swap(i, j): -    x = MAIN[i] -    MAIN[i] = MAIN[j] -    MAIN[j] = x - - -update = True -while update == True: -    update = False -    for i in range(1, N): -        if MAIN[i][1] > MAIN[i - 1][1]: -            continue -        elif MAIN[i][1] == MAIN[i - 1][1]: -            if MAIN[i][2] > MAIN[i - 1][2]: -                swap(i, i - 1) -                update = True -        else: -            swap(i, i - 1) -            update = True -for m in MAIN: -    print((m[0])) +    MAIN.append([S, -int(P)]) +ans = sorted(MAIN) +for m in ans: +    print((MAIN.index(m) + 1))