module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readTuple2' :: IO (String, Int)
readTuple2' = do
    [a, b] <- words <$> getLine
    return (a, read b)
    

main = do
    n <- readInt
    sps <- replicateM n readTuple2'
    let sps2 = zip [1..] sps
    let sorted = sortOn (fst . snd) $ sortOn (negate  . snd . snd) sps2
    forM_ sorted $ \(num, _) ->
        print num


