N = int(input())

cities = {}
for i in range(1, N + 1):
    s, p = input().split()
    p = int(p)
    if s in cities:
        cities[s].append((p, i))
    else:
        cities[s] = [(p, i)]
for k in cities.keys():
    cities[k] = list(sorted(cities[k], key=lambda x: x[0], reverse=True))

names = sorted(cities)
for name in names:
    for p, i in cities[name]:
        print(i) N = int(input()) N int(input()) int input() input cities = {} cities {} for i in range(1, N + 1):
    s, p = input().split()
    p = int(p)
    if s in cities:
        cities[s].append((p, i))
    else:
        cities[s] = [(p, i)] i range(1, N + 1) range 1 N + 1 N 1 s, p = input().split() s input().split() ().split () input split p p = int(p) p int(p) int p if s in cities:
        cities[s].append((p, i))
    else:
        cities[s] = [(p, i)] s in cities s cities cities[s].append((p, i)) [s].append [s] cities s append (p, i) p i cities[s] = [(p, i)] cities[s] cities s [(p, i)] (p, i) p i for k in cities.keys():
    cities[k] = list(sorted(cities[k], key=lambda x: x[0], reverse=True)) k cities.keys() cities.keys cities keys cities[k] = list(sorted(cities[k], key=lambda x: x[0], reverse=True)) cities[k] cities k list(sorted(cities[k], key=lambda x: x[0], reverse=True)) list sorted(cities[k], key=lambda x: x[0], reverse=True) sorted cities[k] cities k key=lambda x: x[0] key lambda x: x[0] x[0] x 0 x reverse=True reverse True names = sorted(cities) names sorted(cities) sorted cities for name in names:
    for p, i in cities[name]:
        print(i) name names for p, i in cities[name]:
        print(i) p i cities[name] cities name print(i) print i names = sorted(cities) sorted(cities) names N = int(input()) int(input()) N p = input().split() input().split() p cities = {} {} cities s, p = input().split() input().split() s p = int(p) int(p) p
N = int(input())

cities = {}
for i in range(1, N + 1):
    s, p = input().split()
    p = int(p)
    if s in cities:
        cities[s].append((p, i))
    else:
        cities[s] = [(p, i)]
for k in cities.keys():
    cities[k] = list(sorted(cities[k], key=lambda x: x[0], reverse=True))

names = sorted(cities)
for name in names:
    for p, i in cities[name]:
        print(i)
