import Control.Monad

import Data.Ord
import Data.List
import Data.Function
import Data.Maybe

import qualified Data.ByteString.Char8 as BS

import Debug.Trace

tuplify :: [String] -> (String, Integer)
tuplify (x:y:_) = (x, - read y)
tuplify _ = undefined

--Input functions by ByteString
readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

readStrTuple = tuplify . words

getIntList = readIntList <$> BS.getLine

getStrTuples = map readStrTuple . lines <$> getContents

main = do
  [n] <- getIntList
  sps <- getStrTuples
  mapM_ print . map fst . sortBy (compare `on` snd) $ zip [1..n] sps