#include <bits/stdc++.h>
using namespace std;
const int maxn = 500010;
int n, m, K, Q, top;
int pa[maxn], pb[maxn], last[maxn], pre[maxn], nxt[maxn], qa[maxn], qb[maxn],
    f[51][maxn], rnk[51][maxn];
bool g[51][maxn];
int sa[maxn], sb[maxn];
vector<int> v[maxn << 2];
vector<int>::iterator it;
void updata(int l, int r, int x, int a, int b, int c) {
  if (a <= l && r <= b) {
    v[x].push_back(c);
    return;
  }
  int mid = (l + r) >> 1;
  if (a <= mid) updata(l, mid, x << 1, a, b, c);
  if (b > mid) updata(mid + 1, r, x << 1 | 1, a, b, c);
}
void dfs(int l, int r, int x) {
  int now = top;
  for (it = v[x].begin(); it != v[x].end(); it++) {
    if (!qb[*it]) continue;
    int x = pa[qa[*it]], y = pb[qa[*it]], z = qb[*it];
    bool flag = 1;
    while (f[z][x]) flag ^= g[z][x], x = f[z][x];
    while (f[z][y]) flag ^= g[z][y], y = f[z][y];
    if (x == y) continue;
    if (rnk[z][x] > rnk[z][y]) swap(x, y);
    f[z][x] = y, g[z][x] = flag, sa[++top] = x, sb[top] = z;
    if (rnk[z][x] == rnk[z][y]) rnk[z][y]++, sb[top] = -z;
  }
  if (l == r) {
    int x = pa[qa[l]], y = pb[qa[l]], z = qb[l];
    bool flag = 1;
    while (f[z][x]) flag ^= g[z][x], x = f[z][x];
    while (f[z][y]) flag ^= g[z][y], y = f[z][y];
    if (x == y && flag)
      qb[l] = qb[pre[l]], cout << "NO" << endl;
    else
      cout << "YES" << endl;
    while (top > now) {
      if (sb[top] < 0) sb[top] = -sb[top], rnk[sb[top]][f[sb[top]][sa[top]]]--;
      f[sb[top]][sa[top]] = 0, top--;
    }
    return;
  }
  int mid = (l + r) >> 1;
  dfs(l, mid, x << 1), dfs(mid + 1, r, x << 1 | 1);
  while (top > now) {
    if (sb[top] < 0) sb[top] = -sb[top], rnk[sb[top]][f[sb[top]][sa[top]]]--;
    f[sb[top]][sa[top]] = 0, top--;
  }
}
int main() {
  cin >> n >> m >> K >> Q;
  for (int i = 1; i <= m; i++) cin >> pa[i] >> pb[i];
  for (int i = 1; i <= Q; i++) {
    cin >> qa[i] >> qb[i];
    if (last[qa[i]]) nxt[last[qa[i]]] = i, pre[i] = last[qa[i]];
    last[qa[i]] = i, nxt[i] = Q + 1;
  }
  for (int i = 1; i <= Q; i++)
    if (i + 1 <= nxt[i] - 1) updata(1, Q, 1, i + 1, nxt[i] - 1, i);
  dfs(1, Q, 1);
}
