Scanf.scanf "%d %d %d" (fun n m q ->
    let mat = Array.make_matrix n n 0 in
    for i = 1 to m do
        Scanf.scanf " %d %d" (fun l r ->
            mat.(l - 1).(r - 1) <- mat.(l - 1).(r - 1) + 1;
        )
    done;
    for y = n - 2 downto 0 do
        for x = 0 to n - 1 do
            mat.(y).(x) <- mat.(y).(x) + mat.(y + 1).(x)
        done
    done;
    for y = 0 to n - 1 do
        for x = 1 to n - 1 do
            mat.(y).(x) <- mat.(y).(x) + mat.(y).(x - 1)
        done
    done;
    for i = 1 to q do
        Scanf.scanf " %d %d" (fun p1 q1 ->
            Printf.printf "%d\n" @@ mat.(p1 - 1).(q1 - 1)
        )
    done
)