n = int(input())
r = []
for i in range(n):
    city, score = map(str, input().split())
    score = int(score)
    r.append((city, score, i+1))

r.sort(key=lambda x: x[1], reverse=True)
r.sort(key=lambda x: x[0])

for x in r:
    print(x[2])
