#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(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 fractions import gcd from itertools import combinations,permutations,accumulate from collections import deque,defaultdict,Counter import decimal decimal import re re import sys sys sys.setrecursionlimit(10000000) sys.setrecursionlimit sys setrecursionlimit 10000000 mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 def readInts():
  return list(map(int,input().split())) readInts return list(map(int,input().split())) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split def I():
  return int(input()) I return int(input()) int(input()) int input() input n = I() n I() I ans = [] ans [] for i in range(n):
    name,score = input().split()
    score = int(score)
    ans.append([name,score,i+1]) i range(n) range n name,score = input().split() name input().split() ().split () input split score score = int(score) score int(score) int score ans.append([name,score,i+1]) ans.append ans append [name,score,i+1] name score i+1 i 1 ans = sorted(ans,key = lambda x:x[1],reverse = True) ans sorted(ans,key = lambda x:x[1],reverse = True) sorted ans key = lambda x:x[1] key lambda x:x[1] x[1] x 1 x reverse = True reverse True ans = sorted(ans,key = lambda x:x[0]) ans sorted(ans,key = lambda x:x[0]) sorted ans key = lambda x:x[0] key lambda x:x[0] x[0] x 0 x for i in range(n):
    print(ans[i][2]) i range(n) range n print(ans[i][2]) print ans[i][2] [i] ans i 2 n = I() I() n score = input().split() input().split() score name,score = input().split() input().split() name ans = sorted(ans,key = lambda x:x[0]) sorted(ans,key = lambda x:x[0]) ans mod = 10**9 + 7 10**9 + 7 mod def I():
  return int(input()) def I():
  return int(input()) I def readInts():
  return list(map(int,input().split())) def readInts():
  return list(map(int,input().split())) readInts ans = [] [] ans score = int(score) int(score) score ans = sorted(ans,key = lambda x:x[1],reverse = True) sorted(ans,key = lambda x:x[1],reverse = True) ans
#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(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])
