N = int(eval(input()))

city = dict()

restaurants = []

for _ in range(N):

    s, p = input().split()

    restaurants.append([s, int(p)])

    if s in list(city.keys()):

        city[s].append(int(p))

    else:

        city[s] = [int(p)]



city = sorted(list(city.items()), key=lambda x:x[0])



for c in city:

    points = c[1]

    points.sort(reverse=True)

    for p in points:

        for i in range(N):

            s = c[0]

            r = restaurants[i]

            if r[0] == s and r[1] == p:

                print((i + 1))
from collections import defaultdict

n = int(eval(input()))

restaurants = defaultdict(list)

for i in range(n):

    s, p = input().split()

    p = int(p)

    restaurants[s].append([p, i])



cnt = 0

for k, v in sorted(list(restaurants.items()), key=lambda x: x[0]):

    for p, i in sorted(v, key=lambda x: -x[0]):

        print((i + 1))

N = int(eval(input()))
city = dict()
restaurants = []
for _ in range(N):
    s, p = input().split()
    restaurants.append([s, int(p)])
    if s in list(city.keys()):
        city[s].append(int(p))
    else:
        city[s] = [int(p)]
city = sorted(list(city.items()), key=lambda x: x[0])
for c in city:
    points = c[1]
    points.sort(reverse=True)
    for p in points:
        for i in range(N):
            s = c[0]
            r = restaurants[i]
            if r[0] == s and r[1] == p:
                print((i + 1))

from collections import defaultdict

n = int(eval(input()))
restaurants = defaultdict(list)
for i in range(n):
    s, p = input().split()
    p = int(p)
    restaurants[s].append([p, i])
cnt = 0
for k, v in sorted(list(restaurants.items()), key=lambda x: x[0]):
    for p, i in sorted(v, key=lambda x: -x[0]):
        print((i + 1))

-N = int(eval(input())) -city = dict() -restaurants = [] -for _ in range(N): +from collections import defaultdict + +n = int(eval(input())) +restaurants = defaultdict(list) +for i in range(n): -    restaurants.append([s, int(p)]) -    if s in list(city.keys()): -        city[s].append(int(p)) -    else: -        city[s] = [int(p)] -city = sorted(list(city.items()), key=lambda x: x[0]) -for c in city: -    points = c[1] -    points.sort(reverse=True) -    for p in points: -        for i in range(N): -            s = c[0] -            r = restaurants[i] -            if r[0] == s and r[1] == p: -                print((i + 1)) +    p = int(p) +    restaurants[s].append([p, i]) +cnt = 0 +for k, v in sorted(list(restaurants.items()), key=lambda x: x[0]): +    for p, i in sorted(v, key=lambda x: -x[0]): +        print((i + 1))