
N = int(input())

SP = []
for i in range(N):
    hoge = list(input().split())
    SP.append([hoge[0], int(hoge[1]), i+1])
SP = sorted(SP, key=lambda x:-x[1])
SP = sorted(SP, key=lambda x:x[0])

for i in SP:
    print(i[2])
