import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

n = int(input())

r = []

for i in range(n):
    city, score = input().split()
    score = int (score)
    r.append((i+1, city, score))

r.sort(key=lambda x:x[2], reverse=True)
r.sort(key=lambda x:x[1])

for i in range(n):
    print(r[i][0]) import sys sys import math math import itertools itertools import bisect bisect from copy import copy from collections import deque,Counter from decimal import Decimal def s(): return input() s def i(): return int(input()) i def S(): return input().split() S def I(): return map(int,input().split()) I def X(): return list(input()) X def L(): return list(input().split()) L def l(): return list(map(int,input().split())) l def lcm(a,b): return a*b//math.gcd(a,b) lcm a a b b def gcd(*numbers): reduce(math.gcd, numbers) gcd *numbers sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 count = 0 count 0 ans = 0 ans 0 n = int(input()) n int(input()) int input() input r = [] r [] for i in range(n):
    city, score = input().split()
    score = int (score)
    r.append((i+1, city, score)) i range(n) range n city, score = input().split() city input().split() ().split () input split score score = int (score) score int (score) int score r.append((i+1, city, score)) r.append r append (i+1, city, score) i+1 i 1 city score r.sort(key=lambda x:x[2], reverse=True) r.sort r sort key=lambda x:x[2] key lambda x:x[2] x[2] x 2 x reverse=True reverse True r.sort(key=lambda x:x[1]) r.sort r sort key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x for i in range(n):
    print(r[i][0]) i range(n) range n print(r[i][0]) print r[i][0] [i] r i 0 def I(): return map(int,input().split()) def I(): return map(int,input().split()) I ans = 0 0 ans city, score = input().split() input().split() city def gcd(*numbers): reduce(math.gcd, numbers) def gcd(*numbers): reduce(math.gcd, numbers) gcd def S(): return input().split() def S(): return input().split() S def i(): return int(input()) def i(): return int(input()) i def s(): return input() def s(): return input() s n = int(input()) int(input()) n def L(): return list(input().split()) def L(): return list(input().split()) L def lcm(a,b): return a*b//math.gcd(a,b) def lcm(a,b): return a*b//math.gcd(a,b) lcm mod = 10**9+7 10**9+7 mod def X(): return list(input()) def X(): return list(input()) X score = input().split() input().split() score def l(): return list(map(int,input().split())) def l(): return list(map(int,input().split())) l r = [] [] r score = int (score) int (score) score count = 0 0 count
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

n = int(input())

r = []

for i in range(n):
    city, score = input().split()
    score = int (score)
    r.append((i+1, city, score))

r.sort(key=lambda x:x[2], reverse=True)
r.sort(key=lambda x:x[1])

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