import Data.List
import Control.Monad

my_comp::((String,Int),Int)->((String,Int),Int)->Ordering
my_comp ((st1,i1),_) ((st2,i2),_) = case compare st1 st2 of
                            EQ -> compare i2 i1
                            o  -> o

solver::[((String,Int),Int)]->[Int]
solver = map snd . sortBy my_comp

main::IO()
main=do
  n<-return. read =<< getLine
  dat <- forM [1..n] (\_->return. (\ (s:p:_) -> (s,read p) ) .words =<< getLine)
  forM_ (solver (zip dat [1..])) print
