import pandas as pd

N=int(input())

datalist=[]
for i in range(N):
    a=input().split()
    datalist.append([i+1]+a)

df=pd.DataFrame(datalist)
df.columns=["num","name","point"]
df.sort_values(by="point",inplace=True,ascending=False)
df.sort_values(by="name",inplace=True)
df.reset_index(inplace=True)
for i in range(N):
    print df.num[i]
