import sys, bisect, math, itertools, string, queue, copy
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

l = []
n = inp()
for i in range(1, n+1):
    r = input().split()
    s = r[0]
    p = int(r[1])
    l.append([i, s, p])
ans = sorted(l, key=lambda x:(x[1], -x[2]))
for t in ans:
    print(t[0]) import sys, bisect, math, itertools, string, queue, copy sys bisect math itertools string queue copy mod = 10**9+7 mod 10**9+7 10**9 10 9 7 def inp(): return int(input()) inp def inpm(): return map(int,input().split()) inpm def inpl(): return list(map(int, input().split())) inpl def inpls(): return list(input().split()) inpls def inplm(n): return list(int(input()) for _ in range(n)) inplm n n list(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list(input()) list input() input def inplL(n): return [list(input()) for _ in range(n)] inplL n n tuple(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) tuple(input()) tuple input() input def inplT(n): return [tuple(input()) for _ in range(n)] inplT n n list(map(int, input().split())) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def inpll(n): return [list(map(int, input().split())) for _ in range(n)] inpll n n list(map(int, input().split())) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) inplls n n l = [] l [] n = inp() n inp() inp for i in range(1, n+1):
    r = input().split()
    s = r[0]
    p = int(r[1])
    l.append([i, s, p]) i range(1, n+1) range 1 n+1 n 1 r = input().split() r input().split() ().split () input split s = r[0] s r[0] r 0 p = int(r[1]) p int(r[1]) int r[1] r 1 l.append([i, s, p]) l.append l append [i, s, p] i s p ans = sorted(l, key=lambda x:(x[1], -x[2])) ans 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 t in ans:
    print(t[0]) t ans print(t[0]) print t[0] t 0 def inpll(n): return [list(map(int, input().split())) for _ in range(n)] def inpll(n): return [list(map(int, input().split())) for _ in range(n)] inpll def inp(): return int(input()) def inp(): return int(input()) inp l = [] [] l r = input().split() input().split() r def inplm(n): return list(int(input()) for _ in range(n)) def inplm(n): return list(int(input()) for _ in range(n)) inplm def inpl(): return list(map(int, input().split())) def inpl(): return list(map(int, input().split())) inpl def inplT(n): return [tuple(input()) for _ in range(n)] def inplT(n): return [tuple(input()) for _ in range(n)] inplT s = r[0] r[0] s def inplL(n): return [list(input()) for _ in range(n)] def inplL(n): return [list(input()) for _ in range(n)] inplL p = int(r[1]) int(r[1]) p def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) inplls mod = 10**9+7 10**9+7 mod ans = sorted(l, key=lambda x:(x[1], -x[2])) sorted(l, key=lambda x:(x[1], -x[2])) ans def inpls(): return list(input().split()) def inpls(): return list(input().split()) inpls n = inp() inp() n def inpm(): return map(int,input().split()) def inpm(): return map(int,input().split()) inpm
import sys, bisect, math, itertools, string, queue, copy
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

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