import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (groupBy)
import Data.Function (on)

main :: IO ()
main = do
  n <- unsafeSignedDecimal <$> T.getLine :: IO Int
  sps <- sequence . replicate n $ fmap unsafeSignedDecimal . unsafeListToTuple . T.words <$> T.getLine :: IO [(T.Text, Int)]
  let
    spis = zipWith (\(s, p) i -> (s, (p, i))) sps [1..n]
  mapM_ print . concat . map (map snd . reverse . sortBy (compare `on` fst) . map snd) . groupBy ((==) `on` fst) . sortBy (compare `on` fst) $ spis

unsafeListToTuple :: [T.Text] -> (T.Text, T.Text)
unsafeListToTuple (x : y : _) = (x, y)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
