N=input()
N=int(N)
S=[100]*N
P=[100]*N
for num in range(N):
    S[num]=input().split()
    S[num].append(num+1)
    S[num][1]=int(S[num][1])

S.sort()
flag=0
flag2=0
while(flag==0):
    flag2=0
    for num in range(0,N-1):
        if(S[num][0]==S[num+1][0]):
            if(S[num][1]<S[num+1][1]):
                S[num],S[num+1]=S[num+1],S[num]
                flag2=1
    if(flag2==0):
        flag=1
    
            

for num in range(N):
    print(S[num][2])
