import Control.Applicative ((<$>)) import Control.Monad (when, forM_) import qualified Data.Vector as V import Data.Vector (Vector, (!)) import qualified Data.Vector.Mutable as VM import Data.Vector.Mutable (IOVector) main :: IO () main = do n <- readLn vab <- V.generateM n f m <- readLn vxy <- V.generateM m f vc <- VM.replicate m 0 :: IO (IOVector Int) forM_ [0..n-1] $ \i -> do let (a, b) = vab ! i forM_ [0..m-1] $ \j -> do let (x, y) = vxy ! j when (a >= x && b <= y) $ VM.modify vc (+1) j vc' <- V.freeze vc pr $ snd $ V.ifoldl' g (0, []) vc' where f _ = do [l, m] <- map read <$> words <$> getLine :: IO [Int] return (l, m) g (mx, ls) i v | v == 0 = (mx, ls) | v > mx = (v, [i+1]) | v == mx = (mx, (i+1) : ls) | otherwise = (mx, ls) pr ls | null ls = print 0 | otherwise = mapM_ print $ reverse ls