import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  [ss, ps] <- transpose . map words <$> replicateM n getLine
  let rs = zip3 ss (map (negate . read :: String -> Int) ps) [1..]
  mapM_ (\(_, _, a) -> print a) $ sort rs

