n = int(input())

a = []

for i in range(n):
  	# input as str
	s, p = input().split()
    # p -> integer
	p = int(score)
    # create list
	a.append((s, p, i+1))

# sort
a.sort(key=lambda x:x[1], reverse=True)

# sort
a.sort(key=lambda x:x[0])

# output
for i in range(n):
	print(a[i][2])