# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N = int(input())
L = []
for i in range(N):
    c, p = input().split()
    p = int(p)
    L.append([i+1, c, p])
L = sorted(L, key=lambda x: (x[1], -x[2]))
for i in range(N):
    print(L[i][0]) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N = int(input()) N int(input()) int input() input L = [] L [] for i in range(N):
    c, p = input().split()
    p = int(p)
    L.append([i+1, c, p]) i range(N) range N c, p = input().split() c input().split() ().split () input split p p = int(p) p int(p) int p L.append([i+1, c, p]) L.append L append [i+1, c, p] i+1 i 1 c p 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 2 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 c, p = input().split() input().split() c input = sys.stdin.readline sys.stdin.readline input N = int(input()) int(input()) N L = [] [] L p = input().split() input().split() p p = int(p) int(p) p L = sorted(L, key=lambda x: (x[1], -x[2])) sorted(L, key=lambda x: (x[1], -x[2])) L
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N = int(input())
L = []
for i in range(N):
    c, p = input().split()
    p = int(p)
    L.append([i+1, c, p])
L = sorted(L, key=lambda x: (x[1], -x[2]))
for i in range(N):
    print(L[i][0])
