#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
const int N = 100010;
const int M = 2000000;
const int HISTORY_SIZE = 10000000;
char historyBuffer[HISTORY_SIZE], *historyPos = historyBuffer;
template <class T>
T &Do(T &x) {
  *((void **)historyPos) = &x;
  historyPos += 8;
  *((T *)historyPos) = x;
  historyPos += sizeof(T);
  *historyPos = sizeof(T);
  historyPos++;
  return x;
}
void Undo() {
  historyPos--;
  int size = *historyPos;
  historyPos -= size + 8;
  memcpy(*((void **)historyPos), (void *)(historyPos + 8), size);
}
void Undo(char *pos) {
  for (; historyPos > pos; Undo())
    ;
}
vector<int> m[N];
int p[M];
int fnd(int i) { return p[i] = p[i] == i ? i : fnd(p[i]); }
void uni(int i, int j) { p[fnd(i)] = fnd(j); }
int dofnd(int i) { return Do(p[i]) = p[i] == i ? i : dofnd(p[i]); }
void douni(int i, int j) { Do(p[dofnd(i)]) = dofnd(j); }
struct T {
  int l, r, c, k;
  int a[5], b[5];
  T() { c = -1; }
};
T operator+(const T &a, const T &b) {
  if (a.c == -1) return b;
  if (b.c == -1) return a;
  T c;
  c.c = a.c + b.c;
  c.l = a.l;
  c.r = b.r;
  int i;
  for (i = 0; i < 5 && i < b.r - b.l + 1; c.a[i] = b.a[i], i++)
    ;
  for (; i < 5 && i < b.r - b.l + 1 + a.r - a.l + 1;
       c.a[i] = a.a[i - (b.r - b.l + 1)], i++)
    ;
  for (i = 0; i < 5 && i < a.r - a.l + 1; c.b[i] = a.b[i], i++)
    ;
  for (; i < 5 && i < a.r - a.l + 1 + b.r - b.l + 1;
       c.b[i] = b.b[i - (a.r - a.l + 1)], i++)
    ;
  for (i = a.r; i >= a.l && i >= a.r - 4; i--)
    for (auto j : m[i])
      if (j >= b.l && j <= b.r)
        if (dofnd(a.a[a.r - i]) != dofnd(b.b[j - b.l])) {
          c.c--;
          douni(a.a[a.r - i], b.b[j - b.l]);
        }
  return c;
}
T operator-(const T &a, const T &b) {
  T c;
  c.k = a.k + 1;
  if (a.c == -1 && b.c == -1) return c;
  if (a.c == -1) {
    c.l = b.l;
    c.r = b.r;
  } else if (b.c == -1) {
    c.l = a.l;
    c.r = a.r;
  } else {
    c.l = a.l;
    c.r = b.r;
  }
  int i;
  for (i = 0; i < 5 && i < c.r - c.l + 1; c.a[i] = c.k * N + c.r - i, i++)
    ;
  for (i = 0; i < 5 && i < c.r - c.l + 1; c.b[i] = c.k * N + c.l + i, i++)
    ;
  c.c = c.r - c.l + 1;
  for (i = c.l; i <= c.r; i++)
    for (auto j : m[i])
      if (j >= c.l && j <= c.r)
        if (fnd(c.k * N + i) != fnd(c.k * N + j)) {
          c.c--;
          uni(c.k * N + i, c.k * N + j);
        }
  for (i = c.l; i <= c.r; fnd(c.k * N + i), i++)
    ;
  return c;
}
T t[1 << 18];
int h = 1 << 17;
T fnd(int i, int j) {
  T a, b;
  for (i += h, j += h; i <= j; i = (i + 1) / 2, j = (j - 1) / 2) {
    if (i % 2) a = a + t[i];
    if (~j % 2) b = t[j] + b;
  }
  return a + b;
}
int main() {
  int i, j, n, k;
  scanf("%d%d", &n, &k);
  scanf("%d", &k);
  for (; k--;) {
    scanf("%d%d", &i, &j);
    i--;
    j--;
    if (j < i) swap(i, j);
    m[i].push_back(j);
  }
  for (i = 0; i < M; p[i] = i, i++)
    ;
  for (i = 0; i < n; i++) {
    t[i + h].k = 0;
    t[i + h].l = i;
    t[i + h].r = i;
    t[i + h].c = 1;
    t[i + h].a[0] = i;
    t[i + h].b[0] = i;
  }
  for (i = h - 1; i > 0; t[i] = t[2 * i] - t[2 * i + 1], i--)
    ;
  scanf("%d", &k);
  for (; k--;) {
    scanf("%d%d", &i, &j);
    i--, j--;
    char *undoPos = historyPos;
    printf("%d\n", fnd(i, j).c);
    Undo(undoPos);
  }
  return 0;
}
