N = int(input())
list1 = [(input() + " " + str(i+1)).split() for i in range(N)]
 
list1 = [k for k in list1]
 
list1.sort(key=lambda k: int(k[1]), reverse=True)
list1.sort(key=lambda k: k[0])
 
 
for i in list1:
    print(i[2])
