import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  sps <- replicateM n readInput
  forM_ (solve n sps) $ \i -> do
    print i

readInput :: IO (String, Int)
readInput = do
  [s, p] <- words <$> getLine
  return (s, read p)

solve :: Int -> [(String, Int)] -> [Int]
solve n sps = map snd $ sort $ zip sps [n, n-1 ..]