import Data.List
import Control.Monad
main = do
  getLine
  sps <- map (\[s,p] -> (s, read p)) . map words . lines <$> getContents :: IO [(String, Int)]
  print (swap $ sort $ zip sps [1..])
  forM_ (swap $ sort $ zip sps [1..]) (\x -> print $ snd x)

swap :: [((String,Int),Int)] -> [((String, Int),Int)]
swap [] = [] 
swap (x:y:xs) 
  | ((fst $ fst x) == (fst $ fst y)) && ((snd $ fst x) < (snd $ fst y)) = y : x : swap xs
  | otherwise = x : y : swap xs