#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
struct Edge {
  int u, v;
} e[N];
int n, m, q, p, s[N], x[N], c[N], t[N];
bool ans[N];
struct Node {
  int c, u, v, fa, rk;
  bool ds;
  Node(int _c = 0, int _u = 0, int _v = 0, int _fa = 0, int _rk = 0,
       bool _ds = 0) {
    c = _c;
    u = _u;
    v = _v;
    fa = _fa;
    rk = _rk;
    ds = _ds;
  }
} st[N];
int top;
struct USF {
  int fa[N], rk[N], c;
  bool ds[N];
  void init(int n, int _c) {
    c = _c;
    for (int i = 1; i <= n; ++i) {
      fa[i] = i;
      rk[i] = 0;
      ds[i] = 0;
    }
  }
  int unite(int u, int v) {
    bool du = 0, dv = 0;
    while (u != fa[u]) du ^= ds[u], u = fa[u];
    while (v != fa[v]) dv ^= ds[v], v = fa[v];
    if (u == v) return du ^ dv;
    if (rk[u] < rk[v]) {
      swap(u, v);
      swap(du, dv);
    }
    st[++top] = Node(c, u, v, fa[v], rk[u], ds[v]);
    fa[v] = u;
    ds[v] = du ^ dv ^ 1;
    if (rk[u] == rk[v]) rk[u]++;
    return 2;
  }
} usf[51];
void undo(int t) {
  while (t--) {
    Node &o = st[top];
    --top;
    usf[o.c].fa[o.v] = o.fa;
    usf[o.c].ds[o.v] = o.ds;
    usf[o.c].rk[o.u] = o.rk;
  }
}
vector<pair<int, int> > tr[1 << 20];
void insert(int a, int b, pair<int, int> op, int k, int l, int r) {
  if (a > r || b < l) return;
  if (a <= l && r <= b) {
    tr[k].push_back(op);
    return;
  }
  int lk = (k << 1) + 1, rk = (k << 1) + 2, mid = (l + r) >> 1;
  insert(a, b, op, lk, l, mid);
  insert(a, b, op, rk, mid + 1, r);
}
void solve(int k, int l, int r) {
  int cnt = 0;
  for (auto o : tr[k])
    if (usf[o.first].unite(e[o.second].u, e[o.second].v) == 2) cnt++;
  if (l == r) {
    int xx = x[l], cc = c[l];
    int op = usf[cc].unite(e[xx].u, e[xx].v);
    if (op == 2) cnt++;
    if (op) s[xx] = cc, ans[l] = true;
    if (s[xx]) insert(l + 1, t[l] - 1, make_pair(s[xx], xx), 0, 1, q);
    undo(cnt);
    return;
  }
  int lk = (k << 1) + 1, rk = (k << 1) + 2, mid = (l + r) >> 1;
  solve(lk, l, mid);
  solve(rk, mid + 1, r);
  undo(cnt);
}
int main() {
  scanf("%d %d %d %d", &n, &m, &p, &q);
  for (int i = 1; i <= p; ++i) usf[i].init(n, i);
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d", &e[i].u, &e[i].v);
  }
  for (int i = 1; i <= q; ++i) {
    scanf("%d %d", &x[i], &c[i]);
  }
  for (int i = 1; i <= m; ++i) s[i] = q + 1;
  for (int i = q; i >= 1; --i) {
    t[i] = s[x[i]];
    s[x[i]] = i;
  }
  for (int i = 1; i <= m; ++i) s[i] = 0;
  solve(0, 1, q);
  for (int i = 1; i <= q; ++i) printf(ans[i] ? "YES\n" : "NO\n");
}
