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

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

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