import Data.List (sort)

indexed :: [a] -> [(Int, a)]
indexed xs = go 0 xs
  where
    go i (a:as) = (i, a) : go (1+i) as
    go _ _ = []

splitEvery :: Int -> [a] -> [[a]]
splitEvery _ [] = []
splitEvery n xs = as : splitEvery n bs 
     where (as,bs) = splitAt n xs

solve1 (n:rest) = 
    do {
        (i, [s,p]) <- indexed $ splitEvery 2 rest;
        return (s,100 - (read p), i)
    }

solve2 arr = 
    do {
        (_,_,i) <- sort arr;
        return (1 + i);
    }

main = interact $ unlines.map show.solve2.solve1.words
