import Data.List import Data.Ord main = do gds <- map (map read . words) . tail . lines <$> getContents let r = meguru gds putStr (maybe "NO\n" (unlines . ("YES":) . map show . replicate 6) r) meguru gds = if (snd maxcp) * 6 >= 3000000 then Just (fst maxcp) else Nothing where maxcp = maximumBy (comparing snd) $ zip [1..] (map (\[g,d] -> g - 30000*d) gds)