#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m, Q, x, y, f[N], a[N][8], cnt[8][N], l, r;
int find(int x) {
  if (f[x] == x) return x;
  return f[x] = find(f[x]);
}
int main() {
  scanf("%d%d%d", &n, &m, &m);
  while (m--) {
    scanf("%d%d", &x, &y);
    a[x][y - x] = 1;
  }
  for (int i = 1; i <= n; i++) f[i] = i;
  for (int i = 1; i <= 5; i++)
    for (int j = 1; j + i <= n; j++)
      if (a[j][i]) {
        int x = j, y = j + i, fx = find(x), fy = find(y);
        if (fx == fy) a[j][i] = 0;
        f[fx] = fy;
      }
  for (int i = 1; i <= 5; i++)
    for (int j = 1; j + i <= n; j++) cnt[i][j] = cnt[i][j - 1] + a[j][i];
  scanf("%d", &Q);
  while (Q--) {
    scanf("%d%d", &l, &r);
    int sum = 0;
    for (int i = 1; i <= 5 && i <= r - l; i++)
      sum += cnt[i][r - i] - cnt[i][l - 1];
    printf("%d\n", r - l + 1 - sum);
  }
}
