#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << '{';
  for (int i = (0), __i = (((int)(vec).size())); i < __i; i++) {
    os << vec[i];
    if (i + 1 != ((int)(vec).size())) os << ',';
  }
  os << '}';
  return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &par) {
  os << '(' << par.first << ',' << par.second << ')';
  return os;
}
int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
template <class T>
T sqr(T x) {
  return x * x;
}
vector<int> back[100000];
int p[100000];
int cnt[100000];
bool root[100000];
int par[100000];
int tin[100000];
int tout[100000];
int s[100000];
int main() {
  ios::sync_with_stdio(false);
  int n, m, k, q;
  cin >> n >> m >> k >> q;
  for (int i = (0), __i = (m); i < __i; i++) p[i] = -1;
  for (int i = (0), __i = (n); i < __i; i++) {
    root[i] = true;
    par[i] = -1;
  }
  for (int i = (0), __i = (k); i < __i; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (p[b] != -1) {
      root[a] = false;
      back[p[b]].push_back(a);
      par[a] = p[b];
    }
    p[b] = a;
  }
  int nocry = 0;
  int t = 1;
  queue<int> que;
  for (int i = (0), __i = (n); i < __i; i++)
    if (root[i]) {
      stack<int> st;
      st.push(i);
      while (!st.empty()) {
        int v = st.top();
        if (cnt[v] == 0) tin[v] = t++;
        if (cnt[v] == ((int)(back[v]).size())) {
          tout[v] = t++;
          s[v]++;
          if (par[v] != -1) s[par[v]] += s[v];
          nocry++;
          st.pop();
          continue;
        }
        st.push(back[v][cnt[v]++]);
      }
    }
  for (int i = (0), __i = (q); i < __i; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (p[b] == -1)
      cout << n - nocry;
    else {
      if (tin[a] < tin[p[b]] && tout[p[b]] < tout[a])
        cout << n - nocry + s[a];
      else
        cout << n - nocry;
    }
    cout << endl;
  }
  return 0;
}
