n=int(input())
city={}

for i in range(1,n+1):
    c,p=input().split()
    p=int(p)

    if c in city:
        city[c].append((i,p))
    else:
        city[c]=[(i,p)]

clst=sorted(list(city.keys()))

for c in clst:
    plst=sorted(city[c],key=lambda x:x[1],reverse=True)

    for i,_ in plst:
        print(i) n=int(input()) n int(input()) int input() input city={} city {} for i in range(1,n+1):
    c,p=input().split()
    p=int(p)

    if c in city:
        city[c].append((i,p))
    else:
        city[c]=[(i,p)] i range(1,n+1) range 1 n+1 n 1 c,p=input().split() c input().split() ().split () input split p p=int(p) p int(p) int p if c in city:
        city[c].append((i,p))
    else:
        city[c]=[(i,p)] c in city c city city[c].append((i,p)) [c].append [c] city c append (i,p) i p city[c]=[(i,p)] city[c] city c [(i,p)] (i,p) i p clst=sorted(list(city.keys())) clst sorted(list(city.keys())) sorted list(city.keys()) list city.keys() city.keys city keys for c in clst:
    plst=sorted(city[c],key=lambda x:x[1],reverse=True)

    for i,_ in plst:
        print(i) c clst plst=sorted(city[c],key=lambda x:x[1],reverse=True) plst sorted(city[c],key=lambda x:x[1],reverse=True) sorted city[c] city c key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x reverse=True reverse True for i,_ in plst:
        print(i) i _ plst print(i) print i city={} {} city p=int(p) int(p) p n=int(input()) int(input()) n plst=sorted(city[c],key=lambda x:x[1],reverse=True) sorted(city[c],key=lambda x:x[1],reverse=True) plst c,p=input().split() input().split() c clst=sorted(list(city.keys())) sorted(list(city.keys())) clst p=input().split() input().split() p
n=int(input())
city={}

for i in range(1,n+1):
    c,p=input().split()
    p=int(p)

    if c in city:
        city[c].append((i,p))
    else:
        city[c]=[(i,p)]

clst=sorted(list(city.keys()))

for c in clst:
    plst=sorted(city[c],key=lambda x:x[1],reverse=True)

    for i,_ in plst:
        print(i)
