import collections

from operator import itemgetter

N = int(eval(input()))

SP = []

for i in range(N):

    s,p = input().split()

    SP.append([0,0])

    SP[i][0] = s

    SP[i][1] = int(p)

SP_new = sorted(SP)

t = 0

for i in range(N):

    if t > 0:

        t -= 1

        continue

    s = SP_new[i][0]

    t = 0

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

        if s == SP_new[j][0]:

            t += 1

        else:

            break

    SP_new_new = SP_new[i:i+t+1]

    SP_new_new.sort(key = itemgetter(1))

    for k in range(1,len(SP_new_new)+1):

        u = SP_new_new[-k]

        print((SP.index(u)+1))

N = int(eval(input()))

SP = []

for i in range(N):

    s,p = input().split()

    SP.append([0,0])

    SP[i][0] = s

    SP[i][1] = -int(p)

SP_new = sorted(SP)

for i in SP_new:

    print((SP.index(i)+1))

import collections
from operator import itemgetter

N = int(eval(input()))
SP = []
for i in range(N):
    s, p = input().split()
    SP.append([0, 0])
    SP[i][0] = s
    SP[i][1] = int(p)
SP_new = sorted(SP)
t = 0
for i in range(N):
    if t > 0:
        t -= 1
        continue
    s = SP_new[i][0]
    t = 0
    for j in range(i + 1, N):
        if s == SP_new[j][0]:
            t += 1
        else:
            break
    SP_new_new = SP_new[i : i + t + 1]
    SP_new_new.sort(key=itemgetter(1))
    for k in range(1, len(SP_new_new) + 1):
        u = SP_new_new[-k]
        print((SP.index(u) + 1))

N = int(eval(input()))
SP = []
for i in range(N):
    s, p = input().split()
    SP.append([0, 0])
    SP[i][0] = s
    SP[i][1] = -int(p)
SP_new = sorted(SP)
for i in SP_new:
    print((SP.index(i) + 1))

-import collections -from operator import itemgetter - -    SP[i][1] = int(p) +    SP[i][1] = -int(p) -t = 0 -for i in range(N): -    if t > 0: -        t -= 1 -        continue -    s = SP_new[i][0] -    t = 0 -    for j in range(i + 1, N): -        if s == SP_new[j][0]: -            t += 1 -        else: -            break -    SP_new_new = SP_new[i : i + t + 1] -    SP_new_new.sort(key=itemgetter(1)) -    for k in range(1, len(SP_new_new) + 1): -        u = SP_new_new[-k] -        print((SP.index(u) + 1)) +for i in SP_new: +    print((SP.index(i) + 1))