import Control.Monad
import Data.List
main=do
 n<-readLn :: IO Int
 s<-replicateM n (words<$>getLine)
 let ss=map(\x->[head x,(read(last x)::Int)])s
     sp=zip ss [1..n]
     sq=sortBy(\x y->let p=head(fst x);q=head(fst y);pp=last(fst x);qq=last(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