#from statistics import median

#import collections

#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]

from fractions import gcd

from itertools import combinations,permutations,accumulate # (string,3) 3回

#from collections import deque

from collections import deque,defaultdict,Counter

import decimal

import re

#import bisect

#

#    d = m - k[i] - k[j]

#    if kk[bisect.bisect_right(kk,d) - 1] == d:

#

#

#

# pythonで無理なときは、pypyでやると正解するかも！！

#

#



import sys

sys.setrecursionlimit(10000000)

mod = 10**9 + 7

#mod = 9982443453

def readInts():

  return list(map(int,input().split()))

def I():

  return int(eval(input()))

n = I()

li = []

for i in range(n):

    s,t = input().split()

    li.append([s,int(t),i+1])

li = sorted(li,key = lambda x:x[1], reverse = True)

li = sorted(li,key = lambda x:x[0])

for i in range(n):

    print((li[i][2]))

#from statistics import median

#import collections

#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]

from fractions import gcd

from itertools import combinations,permutations,accumulate # (string,3) 3回

#from collections import deque

from collections import deque,defaultdict,Counter

import decimal

import re

#import bisect

#

#    d = m - k[i] - k[j]

#    if kk[bisect.bisect_right(kk,d) - 1] == d:

#

#

#

# pythonで無理なときは、pypyでやると正解するかも！！

#

#

# my_round_int = lambda x:np.round((x*2 + 1)//2)

# 四捨五入

import sys

sys.setrecursionlimit(10000000)

mod = 10**9 + 7

#mod = 9982443453

def readInts():

  return list(map(int,input().split()))

def I():

  return int(eval(input()))

n = I()

ans = []

for i in range(n):

    name,score = input().split()

    score = int(score)

    ans.append([name,score,i+1])

ans = sorted(ans,key = lambda x:x[1],reverse = True)

ans = sorted(ans,key = lambda x:x[0])

for i in range(n):

    print((ans[i][2]))

# from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations, permutations, accumulate  # (string,3) 3回

# from collections import deque
from collections import deque, defaultdict, Counter
import decimal
import re

# import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
import sys

sys.setrecursionlimit(10000000)
mod = 10**9 + 7
# mod = 9982443453
def readInts():
    return list(map(int, input().split()))


def I():
    return int(eval(input()))


n = I()
li = []
for i in range(n):
    s, t = input().split()
    li.append([s, int(t), i + 1])
li = sorted(li, key=lambda x: x[1], reverse=True)
li = sorted(li, key=lambda x: x[0])
for i in range(n):
    print((li[i][2]))

# from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations, permutations, accumulate  # (string,3) 3回

# from collections import deque
from collections import deque, defaultdict, Counter
import decimal
import re

# import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys

sys.setrecursionlimit(10000000)
mod = 10**9 + 7
# mod = 9982443453
def readInts():
    return list(map(int, input().split()))


def I():
    return int(eval(input()))


n = I()
ans = []
for i in range(n):
    name, score = input().split()
    score = int(score)
    ans.append([name, score, i + 1])
ans = sorted(ans, key=lambda x: x[1], reverse=True)
ans = sorted(ans, key=lambda x: x[0])
for i in range(n):
    print((ans[i][2]))

+# my_round_int = lambda x:np.round((x*2 + 1)//2) +# 四捨五入 -li = [] +ans = [] -    s, t = input().split() -    li.append([s, int(t), i + 1]) -li = sorted(li, key=lambda x: x[1], reverse=True) -li = sorted(li, key=lambda x: x[0]) +    name, score = input().split() +    score = int(score) +    ans.append([name, score, i + 1]) +ans = sorted(ans, key=lambda x: x[1], reverse=True) +ans = sorted(ans, key=lambda x: x[0]) -    print((li[i][2])) +    print((ans[i][2]))