import Data.List
import Control.Monad

main = do
  n <- readLn
  sps <- map words <$> replicateM n getLine
  mapM_ print $ solve sps

solve sps =
  let
    f [a, b] = (a, - (read b))
    spss = zip [1..] $ map f sps
  in
    map fst $ sortOn snd spss