let matrix_from_coord_tuples tuples n =
  let rec inner tuples array = match tuples with
    | [] -> array
    | (s, e)::rest ->
       array.(s).(e) <- array.(s).(e) + 1;
       inner rest array
  in
  inner tuples @@ Array.make_matrix (n+1) (n+1) 0

let x_axis_accum_over_matrix matrix =
  let width = Array.length matrix.(0) in
  let rec inner matrix x y width = match y with
    | y when y = width ->
       matrix
    | _ ->
       matrix.(x).(y) <- matrix.(x).(y-1) + matrix.(x).(y);
       inner matrix x (y+1) width 
  in
  for x = 0 to (Array.length matrix - 1) do
    ignore @@ inner matrix x 1 width
  done;
  matrix

let make_list f t step =
  let rec make_list_inner c t lst =
    if c >= t then lst else make_list_inner (c+step) t (c::lst)
  in
  List.rev (make_list_inner f t [])

let sum_in_rectangle matrix from_coord to_coord =
  let from_x, from_y = from_coord and
      to_x, to_y = to_coord in
  let y_sums = List.map (fun x -> matrix.(x).(to_y) - matrix.(x).(from_y-1)) @@ make_list from_x (to_x+1) 1 in
(*  for i = 0 to (List.length y_sums - 1) do
    Printf.printf "%d " (List.nth y_sums i);
  done;
  print_newline ();*)
  List.fold_left (fun x y -> x + y) 0 y_sums

let solve num_cities trains queries =
  let train_accum_matrix = x_axis_accum_over_matrix (matrix_from_coord_tuples trains num_cities) in
  List.iter (fun (s, e) ->
      begin
        Printf.printf "%d\n" @@ sum_in_rectangle train_accum_matrix (s, s) (e, e)
      end
    ) queries       
       
let read_list_of_int_tuple n =
  let rec read_list_of_int_inner n lst = match n with
    | 0 -> List.rev lst
    | _ ->
       try let ans = (Scanf.scanf "%d %d\n" (fun x y->x,y)) in
           read_list_of_int_inner (n-1) (ans::lst)
       with End_of_file ->
         List.rev lst
  in
  read_list_of_int_inner n []

let () =
  let rec read () =
    try let num_cities, num_trains, num_queries = (Scanf.scanf "%d %d %d\n" (fun x y z -> x, y, z) ) in
        let trains = read_list_of_int_tuple num_trains
        and queries = read_list_of_int_tuple num_queries in
        solve num_cities trains queries
    with End_of_file -> ()
  in
  read ()
;;
