n = int(input())
s_p_list = []

for i in range(n):
    s_p_list.append(input().split())
    s_p_list[i].append(i+1)

result = sorted(s_p_list, key=lambda x: (x[0], -int(x[1]))) #sortedは非破壊的

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