#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5, K = 50 + 5;
int n, m, k, q, prv[N], nxt[N];
vector<int> seg[N << 2];
pair<int, int> ed[N], qu[N];
bool ans[N];
struct DSU {
  pair<int, int> par[N];
  stack<int> records;
  stack<pair<int, pair<int, int>>> history;
  DSU() { fill(par, par + N, make_pair(-1, 0)); }
  void record() { records.push(history.size()); }
  void save(int u) { history.push({u, par[u]}); }
  void undo() {
    int sz = records.top();
    for (records.pop(); history.size() > sz; history.pop())
      par[history.top().first] = history.top().second;
  }
  pair<int, int> get_par(int u) {
    pair<int, int> ans = {u, 0};
    while (par[ans.first].first >= 0) {
      ans.second ^= par[ans.first].second;
      ans.first = par[ans.first].first;
    }
    return ans;
  }
  bool merge(int u, int v) {
    pair<int, int> a = get_par(u);
    pair<int, int> b = get_par(v);
    if (a.first == b.first) return a.second ^ b.second;
    if (par[a.first] > par[b.first]) swap(a, b);
    save(a.first), save(b.first);
    par[a.first].first += par[b.first].first;
    par[b.first] = {a.first, a.second ^ b.second ^ 1};
    return true;
  }
} dsu[K];
bool merge(int p) {
  return dsu[qu[p].second].merge(ed[qu[p].first].first, ed[qu[p].first].second);
}
void update(int l, int r, int id = 1, int st = 0, int en = q) {
  if (r <= st || en <= l) return;
  if (l <= st && en <= r) {
    seg[id].push_back(--l);
    return;
  }
  int mid = st + en >> 1;
  update(l, r, id << 1, st, mid);
  update(l, r, id << 1 | 1, mid, en);
}
void calc(int id = 1, int st = 0, int en = q) {
  for (int i = 0; i < k; i++) dsu[i].record();
  for (auto p : seg[id])
    if (~qu[p].second) merge(p);
  if (en - st > 1) {
    int mid = st + en >> 1;
    calc(id << 1, st, mid);
    calc(id << 1 | 1, mid, en);
  } else if (ans[st] = merge(st))
    prv[qu[st].first] = qu[st].second;
  else
    qu[st].second = prv[qu[st].first];
  for (int i = 0; i < k; i++) dsu[i].undo();
}
void prepare() {
  fill(nxt, nxt + m, q);
  memset(prv, -1, sizeof prv);
  for (int i = q - 1; ~i; i--) {
    update(i + 1, nxt[qu[i].first]);
    nxt[qu[i].first] = i;
  }
}
void read_input() {
  cin >> n >> m >> k >> q;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    ed[i] = {--u, --v};
  }
  for (int i = 0; i < q; i++) {
    int p, c;
    cin >> p >> c;
    qu[i] = {--p, --c};
  }
}
void solve() {
  prepare();
  calc();
}
void write_output() {
  for (int i = 0; i < q; i++) cout << (ans[i] ? "YES\n" : "NO\n");
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read_input(), solve(), write_output();
  return 0;
}
