import Control.Monad
import Data.List
main=do
 n<-readLn :: IO Int
 s<-replicateM n (words<$>getLine)
 let sn=map head s :: [String]
     sv=map read (map last s):: [Int]
     ss=zip sn sv
     sp=zip ss [1..n]
     sq=sortBy(\x y->let p=fst(fst x);q=fst(fst y);pp=snd(fst x);qq=snd(fst y) in if p<q||(p==q&&pp>qq) then LT else if p>q||(p==q&&pp<qq) then GT else EQ)sp
 mapM_ print$map snd sq