import Control.Monad
import Data.List

main = do
  n<-readLn
  sps<-replicateM n$(\[a,b]->(a,read b)).words<$>getLine
  putStr $ solve sps

solve sps = unlines $ map (show.(\(i,(_,_))->i)) ans
  where
  tmp = sortOn (\(_,(_,a))-> -a) isps
  ans = sortOn (\(_,(a,_))-> a) tmp
  isps = zip [1..] sps
  sortOn f = sortBy (\a b->compare(f a)(f b))