module Main where

import Data.List as List
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as BS
import Control.Monad as M
import Data.Maybe as Maybe
import Data.Vector.Algorithms.Intro as Algo
import Control.Monad.ST

data Shop = Shop
        { shopIndex :: !Int
        , shopName :: !BS.ByteString
        , shopScore :: !Int
    } deriving (Eq, Show)

main :: IO ()
main =
    solve =<< readLines =<< getInt

getInt :: IO Int
getInt = read <$> BS.unpack <$> BS.getLine

splitLine :: IO [BS.ByteString]
splitLine = BS.words <$> BS.getLine

readLine :: Int -> [BS.ByteString] -> (Int, BS.ByteString, Int)
readLine n [a, b] = (n, a, read $ BS.unpack b)

readLines :: Int -> IO (V.Vector (Int, BS.ByteString, Int))
readLines n = V.imap readLine <$> V.replicateM n splitLine

compareTuple :: (Int, BS.ByteString, Int) -> (Int, BS.ByteString, Int) -> Ordering
compareTuple (_, a1, b1) (_, a2, b2) = if a1 == a2 then compare b2 b1 else compare a1 a2

{-
getInts :: IO (V.Vector Int)
getInts = V.fromList <$> List.map fst <$> Maybe.mapMaybe BS.readInt <$> replicateM 3 BS.getLine

-}

solve :: V.Vector (Int, BS.ByteString, Int) -> IO ()
solve v = M.foldM (\_ (a, _, _) -> print (a + 1)) () (vecSortBy v compareTuple)

vecSortBy :: Ord a => V.Vector a -> (a -> a -> Ordering) -> V.Vector a
vecSortBy v comp = runST $ do
    mvec <- V.thaw v
    Algo.sortBy comp mvec
    V.freeze mvec
