import Control.Monad

main = do
  l <- getLine
  let [m,q] = map read $ tail $ words l
  lrs <- getpairs m
  pqs <- getpairs q
  mapM (print . compute lrs) pqs

getpairs :: Int -> IO [(Int,Int)]
getpairs n = forM [1..n] $ \_ -> do
  l <- getLine
  let [a,b] = map read $ words l
  return (a,b)

compute lrs (p,q) = length [ () | (l,r) <- lrs, p <= l, r <= q ]