def resolve():
    n=int(input())
    d=[]
    for i in range(n):
        s,p=input().split()
        d.append([s,100-int(p),i])
    d.sort()
    ans=[0]*n
    for i in range(n):
        ans[i]=d[i][2]
    for m in ans:
        print(m+1)
resolve() def resolve():
    n=int(input())
    d=[]
    for i in range(n):
        s,p=input().split()
        d.append([s,100-int(p),i])
    d.sort()
    ans=[0]*n
    for i in range(n):
        ans[i]=d[i][2]
    for m in ans:
        print(m+1) resolve n=int(input()) n int(input()) int input() input d=[] d [] for i in range(n):
        s,p=input().split()
        d.append([s,100-int(p),i])
     i range(n) range n s,p=input().split() s input().split() ().split () input split p d.append([s,100-int(p),i]) d.append d append [s,100-int(p),i] s 100-int(p) 100 int(p) int p i d.sort() d.sort d sort ans=[0]*n ans [0]*n [0] 0 n for i in range(n):
        ans[i]=d[i][2]
     i range(n) range n ans[i]=d[i][2] ans[i] ans i d[i][2] [i] d i 2 for m in ans:
        print(m+1) m ans print(m+1) print m+1 m 1 resolve() resolve def resolve():
    n=int(input())
    d=[]
    for i in range(n):
        s,p=input().split()
        d.append([s,100-int(p),i])
    d.sort()
    ans=[0]*n
    for i in range(n):
        ans[i]=d[i][2]
    for m in ans:
        print(m+1) def resolve():
    n=int(input())
    d=[]
    for i in range(n):
        s,p=input().split()
        d.append([s,100-int(p),i])
    d.sort()
    ans=[0]*n
    for i in range(n):
        ans[i]=d[i][2]
    for m in ans:
        print(m+1) resolve
def resolve():
    n=int(input())
    d=[]
    for i in range(n):
        s,p=input().split()
        d.append([s,100-int(p),i])
    d.sort()
    ans=[0]*n
    for i in range(n):
        ans[i]=d[i][2]
    for m in ans:
        print(m+1)
resolve()