import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  solve n <$> replicateM n f >>= mapM_ print
  where
    f = (\[s, p] -> (s, read p)) <$> words <$> getLine

solve :: Int -> [(String, Int)] -> [Int]
solve n sps = map snd $ sortBy f spis
  where
    spis = zip sps [1 .. n]
    f ((s1, p1),_) ((s2, p2),_)
      | s1 == s2 = compare p2 p1
      | otherwise = compare s1 s2
