open Scanf
open Printf

let rec scan_list = function
  | 1 -> scanf "%d %d " (fun k j -> [k,j])
  | n -> scanf "%d %d " (fun k j -> (k,j) :: scan_list (n-1))

let h lrs (p,q) = List.length @@ List.filter (function k,j -> p <= k && j <= q) lrs

let f n m q = let lrs = scan_list m in
  let pqs = scan_list q in
  List.iter (fun v -> printf "%d\n" @@ h lrs v) pqs

let () = scanf "%d %d %d " f