# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[input().rstrip().split(" ") for i in range(n)]
for i in range(n):
    lis[i][1]=int(lis[i][1])
nl=[]
for i in range(n):
    nl.append([lis[i][0],lis[i][1],i])
nl.sort(key=lambda x:(x[0],-x[1]))
#print(nl)
for i in range(n):
    print(nl[i][2]+1)
        
            
    
    
        
        

    

 import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil,pi,factorial from operator import itemgetter def I(): return int(input()) I def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) LI int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input def LI2(): return [int(input()) for i in range(n)] LI2 [LI()]for i in range(n) for i in range(n) i range(n) range n for i in range(n) [LI()] LI() LI def MXI(): return [[LI()]for i in range(n)] MXI def SI(): return input().rstrip() SI def printns(x): print('\n'.join(x)) printns x x def printni(x): print('\n'.join(list(map(str,x)))) printni x x inf = 10**17 inf 10**17 10 17 mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 n=I() n I() I input().rstrip().split(" ") for i in range(n) for i in range(n) i range(n) range n for i in range(n) input().rstrip().split(" ") ().rstrip().split ().rstrip() ().rstrip () input rstrip split " " lis=[input().rstrip().split(" ") for i in range(n)] lis [input().rstrip().split(" ") for i in range(n)] for i in range(n):
    lis[i][1]=int(lis[i][1]) i range(n) range n lis[i][1]=int(lis[i][1]) lis[i][1] [i] lis i 1 int(lis[i][1]) int lis[i][1] [i] lis i 1 nl=[] nl [] for i in range(n):
    nl.append([lis[i][0],lis[i][1],i]) i range(n) range n nl.append([lis[i][0],lis[i][1],i]) nl.append nl append [lis[i][0],lis[i][1],i] lis[i][0] [i] lis i 0 lis[i][1] [i] lis i 1 i nl.sort(key=lambda x:(x[0],-x[1])) nl.sort nl sort key=lambda x:(x[0],-x[1]) key lambda x:(x[0],-x[1]) (x[0],-x[1]) x[0] x 0 -x[1] x[1] x 1 x for i in range(n):
    print(nl[i][2]+1)
        
            
    
    
        
        

     i range(n) range n print(nl[i][2]+1) print nl[i][2]+1 nl[i][2] [i] nl i 2 1 def SI(): return input().rstrip() def SI(): return input().rstrip() SI def LI2(): return [int(input()) for i in range(n)] def LI2(): return [int(input()) for i in range(n)] LI2 inf = 10**17 10**17 inf n=I() I() n def MI(): return map(int, input().split()) def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI def MXI(): return [[LI()]for i in range(n)] def MXI(): return [[LI()]for i in range(n)] MXI mod = 10**9 + 7 10**9 + 7 mod def I(): return int(input()) def I(): return int(input()) I def printns(x): print('\n'.join(x)) def printns(x): print('\n'.join(x)) printns nl=[] [] nl lis=[input().rstrip().split(" ") for i in range(n)] [input().rstrip().split(" ") for i in range(n)] lis def printni(x): print('\n'.join(list(map(str,x)))) def printni(x): print('\n'.join(list(map(str,x)))) printni input = sys.stdin.readline sys.stdin.readline input
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[input().rstrip().split(" ") for i in range(n)]
for i in range(n):
    lis[i][1]=int(lis[i][1])
nl=[]
for i in range(n):
    nl.append([lis[i][0],lis[i][1],i])
nl.sort(key=lambda x:(x[0],-x[1]))
#print(nl)
for i in range(n):
    print(nl[i][2]+1)
        
            
    
    
        
        

    


