N = int(input())
data = []
cities = []

for i in range(1,N+1):
    c,p = input().split()
    data.append([c,-(int(p)),i])
    if c in cities:
        None
    else:
        cities.append(c)

cities.sort()

ans = []
for c in cities:
    b = [s for s in data if c in s]
    b.sort(key=lambda x: x[1])
    for i in range(len(b)):
        ans.append(b[i])

for i in range(N):
    print(ans[i][2]) N = int(input()) N int(input()) int input() input data = [] data [] cities = [] cities [] for i in range(1,N+1):
    c,p = input().split()
    data.append([c,-(int(p)),i])
    if c in cities:
        None
    else:
        cities.append(c) i range(1,N+1) range 1 N+1 N 1 c,p = input().split() c input().split() ().split () input split p data.append([c,-(int(p)),i]) data.append data append [c,-(int(p)),i] c -(int(p)) int(p) int p i if c in cities:
        None
    else:
        cities.append(c) c in cities c cities None cities.append(c) cities.append cities append c cities.sort() cities.sort cities sort ans = [] ans [] for c in cities:
    b = [s for s in data if c in s]
    b.sort(key=lambda x: x[1])
    for i in range(len(b)):
        ans.append(b[i]) c cities s for s in data if c in s for s in data if c in s s data c in s c s if c in s s b = [s for s in data if c in s] b [s for s in data if c in s] b.sort(key=lambda x: x[1]) b.sort b sort key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x for i in range(len(b)):
        ans.append(b[i]) i range(len(b)) range len(b) len b ans.append(b[i]) ans.append ans append b[i] b i for i in range(N):
    print(ans[i][2]) i range(N) range N print(ans[i][2]) print ans[i][2] [i] ans i 2 c,p = input().split() input().split() c p = input().split() input().split() p N = int(input()) int(input()) N ans = [] [] ans cities = [] [] cities b = [s for s in data if c in s] [s for s in data if c in s] b data = [] [] data
N = int(input())
data = []
cities = []

for i in range(1,N+1):
    c,p = input().split()
    data.append([c,-(int(p)),i])
    if c in cities:
        None
    else:
        cities.append(c)

cities.sort()

ans = []
for c in cities:
    b = [s for s in data if c in s]
    b.sort(key=lambda x: x[1])
    for i in range(len(b)):
        ans.append(b[i])

for i in range(N):
    print(ans[i][2])