import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  sp <- replicateM n getLine
  let spWithNo = map snd $ sort $ zip (map ((\[a, b] ->  (a, 100 - (read :: String -> Int) b)) . words) sp) [1 .. n]
  putStrLn $ unlines $ map show spWithNo
