#include <bits/stdc++.h>
using namespace std;
const int N = 500100;
const int M = 1500100;
int n, m, k, q;
int idx[M], val[N];
int fa[M], ch[M][2];
int size[M], rev[M];
int u[N], v[N], vis[N];
void reverse(int x) {
  if (x == 0) return;
  rev[x] ^= 1;
  swap(ch[x][0], ch[x][1]);
}
void pushdown(int x) {
  if (x == 0) return;
  if (rev[x]) {
    reverse(ch[x][0]);
    reverse(ch[x][1]);
    rev[x] = 0;
  }
}
void maintain(int x) {
  size[x] = (x > m) ^ size[ch[x][0]] ^ size[ch[x][1]];
  idx[x] = x <= m ? x : 0;
  if (idx[x] == 0 || idx[ch[x][0]] && val[idx[x]] > val[idx[ch[x][0]]])
    idx[x] = idx[ch[x][0]];
  if (idx[x] == 0 || idx[ch[x][1]] && val[idx[x]] > val[idx[ch[x][1]]])
    idx[x] = idx[ch[x][1]];
}
int type_(int x) {
  if (ch[fa[x]][0] == x) return 0;
  if (ch[fa[x]][1] == x) return 1;
  return -1;
}
void init_(int x) {
  if (~type_(x)) init_(fa[x]);
  pushdown(x);
}
void rotate(int x) {
  int y = fa[x];
  int d = type_(x);
  int w = ch[x][d ^ 1];
  if (~type_(y)) ch[fa[y]][type_(y)] = x;
  ch[x][d ^ 1] = y;
  ch[y][d] = w;
  fa[x] = fa[y];
  fa[y] = x;
  if (w) fa[w] = y;
  maintain(y);
  maintain(x);
}
void splay(int x) {
  init_(x);
  while (~type_(x)) {
    int y = fa[x];
    if (~type_(y)) {
      if (type_(x) == type_(y))
        rotate(y);
      else
        rotate(x);
    }
    rotate(x);
  }
}
void access(int x) {
  splay(x);
  ch[x][1] = 0;
  maintain(x);
  while (fa[x]) {
    splay(fa[x]);
    ch[fa[x]][1] = x;
    maintain(fa[x]);
    rotate(x);
  }
}
void evert(int x) {
  access(x);
  reverse(x);
  pushdown(x);
}
void link(int x, int y) {
  evert(x);
  evert(y);
  fa[x] = y;
}
void cut_(int x, int y) {
  evert(x);
  access(y);
  fa[x] = 0;
  ch[y][0] = 0;
  maintain(y);
}
void link(int e) {
  vis[e] = 1;
  link(e, u[e]);
  link(e, v[e]);
}
void cut_(int e) {
  if (!vis[e]) return;
  vis[e] = 0;
  cut_(e, u[e]);
  cut_(e, v[e]);
}
bool query(int x, int y) {
  evert(x);
  access(y);
  if (fa[x] == 0)
    return 1;
  else
    return !size[y];
}
void insert(int e) {
  int x = u[e];
  int y = v[e];
  if (x == 0) return;
  evert(x);
  access(y);
  if (fa[x] == 0) {
    link(e);
  } else if (val[idx[y]] < val[e]) {
    cut_(idx[y]);
    link(e);
  }
}
int base[N];
int a[N], b[N];
int x[N], y[N];
int e[N], c[N];
int tab[N], fib[N];
vector<int> vec[55];
int main() {
  cin >> n >> m >> k >> q;
  for (int i = 1; i <= m; i++) scanf("%d%d", a + i, b + i);
  for (int i = 1; i <= q; i++) scanf("%d%d", e + i, c + i);
  for (int i = 1; i <= q; i++) {
    vec[c[i]].push_back(a[e[i]]);
    vec[c[i]].push_back(b[e[i]]);
  }
  base[0] = m;
  for (int i = 1; i <= k; i++) {
    base[i] = base[i - 1] + vec[i - 1].size();
    sort(vec[i].begin(), vec[i].end());
    vec[i].resize(unique(vec[i].begin(), vec[i].end()) - vec[i].begin());
  }
  for (int i = 1; i <= q; i++) {
    x[i] = upper_bound(vec[c[i]].begin(), vec[c[i]].end(), a[e[i]]) -
           vec[c[i]].begin() + base[c[i]];
    y[i] = upper_bound(vec[c[i]].begin(), vec[c[i]].end(), b[e[i]]) -
           vec[c[i]].begin() + base[c[i]];
  }
  for (int i = 1; i <= m; i++) tab[i] = q + 1;
  for (int i = q; i >= 1; i--) {
    fib[i] = tab[e[i]];
    tab[e[i]] = i;
  }
  for (int i = 1; i <= q; i++) {
    cut_(e[i]);
    val[e[i]] = fib[i];
    if (query(x[i], y[i])) {
      u[e[i]] = x[i];
      v[e[i]] = y[i];
      puts("YES");
    } else {
      puts("NO");
    }
    insert(e[i]);
  }
  return 0;
}
