n = int(input())
l = []
for i in range(n):
    x,y = input().split()
    y = int(y)
    l.append([i+1,x,y])

l.sort(key=lambda x: (x[1],(x[2]*-1)))

for i in range(n):
    print(l[i][0])

 n = int(input()) n int(input()) int input() input l = [] l [] for i in range(n):
    x,y = input().split()
    y = int(y)
    l.append([i+1,x,y]) i range(n) range n x,y = input().split() x input().split() ().split () input split y y = int(y) y int(y) int y l.append([i+1,x,y]) l.append l append [i+1,x,y] i+1 i 1 x y l.sort(key=lambda x: (x[1],(x[2]*-1))) l.sort l sort key=lambda x: (x[1],(x[2]*-1)) key lambda x: (x[1],(x[2]*-1)) (x[1],(x[2]*-1)) x[1] x 1 x[2]*-1 x[2] x 2 -1 x for i in range(n):
    print(l[i][0]) i range(n) range n print(l[i][0]) print l[i][0] [i] l i 0 n = int(input()) int(input()) n l = [] [] l y = int(y) int(y) y x,y = input().split() input().split() x y = input().split() input().split() y
n = int(input())
l = []
for i in range(n):
    x,y = input().split()
    y = int(y)
    l.append([i+1,x,y])

l.sort(key=lambda x: (x[1],(x[2]*-1)))

for i in range(n):
    print(l[i][0])


