{-# LANGUAGE BangPatterns      #-} --引数に!

import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromJust)
import Data.List
import qualified Data.Vector.Unboxed.Mutable as V
import Control.Monad
import qualified Data.ByteString.Lazy.Char8 as BS
import Debug.Trace

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- forM [1..n] $ \i -> do
    [s,p] <- words <$> getLine :: IO [String]
    return (i,(s,(read p :: Int)))
  let as' = concat $ map (sortOn (\x -> (0-) $ (snd.snd) x)) $ groupBy (\x y -> (fst.snd) x == (fst.snd) y) $ sortOn (fst.snd) as
  forM_ as' $ \(i,_) -> do
    print (i :: Int)
