import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    sps <- map ((\(x:y:_) -> (x, (read y :: Int))) . words) <$> replicateM n getLine
    mapM_ print . map (\(_, k) -> k) . sortOn (fst . fst) . reverse . sortOn (snd . fst) $ zip sps [1..n]