import Control.Monad
import Control.Applicative
import Data.List

main = do
  n <- readLn
  sp <- replicateM n (words <$> getLine)

  mapM_ print $ solve (list2pair 1 sp)

solve :: [(String, Int, Int)] -> [Int]
solve l = ans
  where
    sorted = mysort l
    buf = sortOn snd (solve' 1 sorted)
    ans = map fst buf

list2pair :: Int -> [[String]] -> [(String, Int, Int)]
list2pair _ [] = []
list2pair n ((s:p:_):rest) = (s,read p, n) : list2pair (n+1) rest

mysort :: [(String,Int,Int)] -> [(String,Int,Int)]
mysort l = sortOn fst3 (reverse (sortOn snd3 l))

fst3 :: Ord a => (a,b,c) -> a
fst3 (n,_,_) = n

snd3 :: Ord b => (a,b,c) -> b
snd3 (_,n,_) = n

solve' :: Int -> [(String, Int, Int)] -> [(Int,Int)]
solve' _ [] = []
solve' m ((_,_,n):rest) = (n,m) : solve' (m+1) rest

