#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

n = int(input())
a = []
for i in range(n):
    s, p = map(str, input().split())
    p = int(p)
    a.append((s,p,i+1))
# 要素[1]を逆ソート
a.sort(key=lambda x:x[1], reverse=True)
# 要素[0]を順ソート
a.sort(key=lambda x:x[0])

for i in range(n):
    print(a[i][2]) n = int(input()) n int(input()) int input() input a = [] a [] for i in range(n):
    s, p = map(str, input().split())
    p = int(p)
    a.append((s,p,i+1))
# 要素[1]を逆ソート i range(n) range n s, p = map(str, input().split()) s map(str, input().split()) map str input().split() ().split () input split p p = int(p) p int(p) int p a.append((s,p,i+1)) a.append a append (s,p,i+1) s p i+1 i 1 a.sort(key=lambda x:x[1], reverse=True) a.sort a sort key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x reverse=True reverse True a.sort(key=lambda x:x[0]) a.sort a sort key=lambda x:x[0] key lambda x:x[0] x[0] x 0 x for i in range(n):
    print(a[i][2]) i range(n) range n print(a[i][2]) print a[i][2] [i] a i 2 p = int(p) int(p) p a = [] [] a s, p = map(str, input().split()) map(str, input().split()) s p = map(str, input().split()) map(str, input().split()) p n = int(input()) int(input()) n
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

n = int(input())
a = []
for i in range(n):
    s, p = map(str, input().split())
    p = int(p)
    a.append((s,p,i+1))
# 要素[1]を逆ソート
a.sort(key=lambda x:x[1], reverse=True)
# 要素[0]を順ソート
a.sort(key=lambda x:x[0])

for i in range(n):
    print(a[i][2])
