import Control.Monad import Data.List import qualified Data.IntMap as M solve gd n = M.filter (>=500000) $ M.fromList $ zip [1..n] $ map e gd where e x = (x !! 0) - 30000 * (x !! 1) output xs | M.null xs = ["NO"] | otherwise = "YES" : (map (show . fst) (gdList xs')) where xs' = M.toList xs gdList a | length a >= 6 = take 6 a | otherwise = gdList (a++a) main = do n <- readLn gd <- map (map read . words) <$> replicateM n getLine putStr $ unlines $ output $ solve gd n