import Data.List (sort)
import Data.List.Grouping (splitEvery)
import Data.List.Index (indexed)

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
