#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
  long long x = 0;
  int ch = getchar(), f = 1;
  while (!isdigit(ch) && (ch != '-') && (ch != EOF)) ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void rt(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10)
    rt(x / 10), putchar(x % 10 + '0');
  else
    putchar(x + '0');
}
const int maxn = 100005;
struct edge {
  int u, v;
  edge(int a = 0, int b = 0) { u = a, v = b; }
  bool operator<(const edge& x) const { return v == x.v ? u > x.u : v < x.v; }
} e[maxn * 5];
struct query {
  int l, r, id;
  query(int a = 0, int b = 0, int c = 0) { l = a, r = b, id = c; }
  bool operator<(const query& x) const { return r < x.r; }
} b[maxn];
int bit[maxn], exi[maxn][6];
int n, k, m, M, q;
int lowbit(int x) { return x & -x; }
void add(int x) {
  while (x <= n) bit[x]++, x += lowbit(x);
}
int qsum(int x) {
  int ret = 0;
  while (x) ret += bit[x], x -= lowbit(x);
  return ret;
}
int ans[maxn];
int main() {
  n = rd(), k = rd(), m = rd();
  for (int i = 1; i <= (int)m; i++) {
    int u = rd(), v = rd();
    if (u > v) swap(u, v);
    e[i] = edge(u, v);
  }
  sort(e + 1, e + m + 1);
  for (int i = 1; i <= (int)m; i++) {
    int u = e[i].u, v = e[i].v, cx = 0;
    for (int j = u + 1; j <= (int)v - 1; j++)
      if (exi[v][v - j] && exi[j][j - u]) cx = 1;
    if (!cx) e[++M] = e[i];
    exi[v][v - u] = 1;
  }
  m = M;
  q = rd();
  for (int i = 1; i <= (int)q; i++) {
    int l = rd(), r = rd();
    b[i] = query(l, r, i);
  }
  sort(b + 1, b + q + 1);
  int zz = 0;
  for (int i = 1; i <= (int)q; i++) {
    while (zz < m && e[zz + 1].v <= b[i].r) zz++, add(e[zz].u);
    ans[b[i].id] = b[i].r - b[i].l + 1 - (zz - qsum(b[i].l - 1));
  }
  for (int i = 1; i <= (int)q; i++) rt(ans[i]), putchar('\n');
}
