#include <bits/stdc++.h>
using namespace std;
pair<int, int> _e[600005], ex[600005];
vector<int> ee[600005];
int nt, rr = 0, dn = 1, colnum, dfnn, _enum, nn, mm, n, m, ca, idnum, num, top,
        hd[600005], dfn[600005], low[600005], instk[600005], a[600005],
        b[600005], col[600005], dffn[600005], dep[600005], fa[600005][20],
        lg[600005], vis[600005], stk[600005], id[600005];
struct enode {
  int to, nxt;
} e[600005];
int rt(int element) {
  element = (element + rr) % nt;
  if (!element) element = nt;
  return element;
}
void add(int u, int v) {
  e[++dn] = (enode){v, hd[u]};
  hd[u] = dn;
}
void tarjan(int x, int lst) {
  int i, v;
  instk[x] = 1, dfn[x] = low[x] = ++dfnn;
  for (i = hd[x]; i; i = e[i].nxt) {
    v = e[i].to;
    if (i == lst || i == (lst ^ 1)) continue;
    if (!dfn[v]) {
      tarjan(v, i);
      if (low[x] > low[v]) low[x] = low[v];
    } else if (instk[v]) {
      if (low[x] > dfn[v]) low[x] = dfn[v];
    }
  }
  for (i = hd[x]; i; i = e[i].nxt) {
    v = e[i].to;
    if (i == lst || i == (lst ^ 1)) continue;
    if (low[v] <= dfn[x]) {
      ee[x].push_back(v);
      ee[v].push_back(x);
    } else
      _e[++_enum] = make_pair(x, v);
  }
  instk[x] = 0;
}
void dfs(int x) {
  col[x] = colnum;
  for (auto v : ee[x])
    if (!col[v]) dfs(v);
}
void dfs1(int x, int father) {
  int i;
  dffn[x] = ++dfnn;
  dep[x] = dep[father] + 1;
  fa[x][0] = father;
  for (i = 1; i <= lg[dep[x]]; i++) fa[x][i] = fa[fa[x][i - 1]][i - 1];
  for (i = hd[x]; i; i = e[i].nxt)
    if (!dffn[e[i].to]) dfs1(e[i].to, x);
}
int getlca(int x, int y) {
  int i;
  if (dep[x] < dep[y]) swap(x, y);
  for (i = lg[dep[x]]; i >= 0; i--)
    if (dep[fa[x][i]] >= dep[y]) x = fa[x][i];
  if (x == y) return x;
  for (i = lg[dep[x]]; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) {
      x = fa[x][i];
      y = fa[y][i];
    }
  return fa[x][0];
}
void add2(int u, int v) {
  add(u, v);
  add(v, u);
}
void dfss(int x) {
  vis[x] = 1;
  for (auto v : ee[x])
    if (!vis[v]) dfss(v);
}
void solve(int t) {
  int i, flag = 1;
  for (i = 1; i <= mm; i++) add2(ex[i].first, ex[i].second);
  _enum = dfnn = 0;
  tarjan(a[1], 0);
  dfss(a[1]);
  for (i = 1; i <= nn; i++)
    if (!vis[a[i]]) flag = 0;
  puts(flag ? "YES" : "NO");
  if (flag) rr = (rr + t) % nt;
  dn = 1;
  for (i = 1; i <= idnum; i++) {
    hd[id[i]] = vis[id[i]] = low[id[i]] = dfn[id[i]] = 0;
    ee[id[i]].clear();
  }
}
void build() {
  int i, lca;
  top = 0, idnum = 0;
  for (i = 1; i <= num; i++) {
    if (!top) {
      stk[top = 1] = b[i];
      id[++idnum] = b[i];
      continue;
    }
    lca = getlca(stk[top], b[i]);
    if (!lca) {
      while (top > 1) {
        add2(stk[top - 1], stk[top]);
        top--;
      }
      stk[top = 1] = b[i];
      id[++idnum] = b[i];
      continue;
    }
    while (top > 1 && dep[stk[top - 1]] > dep[lca]) {
      add2(stk[top - 1], stk[top]);
      top--;
    }
    if (dep[stk[top]] > dep[lca]) add2(lca, stk[top--]);
    if (stk[top] != lca) {
      stk[++top] = lca;
      id[++idnum] = lca;
    }
    stk[++top] = b[i];
    id[++idnum] = b[i];
  }
  while (top > 1) {
    add2(stk[top - 1], stk[top]);
    top--;
  }
}
int main() {
  int i, u, v, t, xx, yy;
  cin >> n >> m >> ca;
  nt = n;
  for (i = 1; i <= m; i++) {
    cin >> u >> v;
    if (u != v) add2(u, v);
  }
  for (i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i, 0);
  for (i = 1; i <= n; i++)
    if (!col[i]) {
      colnum++;
      dfs(i);
    }
  dn = 1;
  for (i = 1; i <= n; i++) hd[i] = 0;
  for (i = 1; i <= _enum; i++) add2(col[_e[i].first], col[_e[i].second]);
  n = colnum;
  dep[0] = -1;
  lg[1] = 0;
  dfnn = 0;
  for (i = 2; i <= n; i++) lg[i] = lg[i >> 1] + 1;
  for (i = 1; i <= n; i++)
    if (!dffn[i]) dfs1(i, 0);
  dn = 1;
  for (i = 1; i <= n; i++) {
    hd[i] = dfn[i] = low[i] = 0;
    ee[i].clear();
  }
  for (t = 1; t <= ca; t++) {
    cin >> nn >> mm;
    num = nn;
    for (i = 1; i <= nn; i++) {
      cin >> xx;
      a[i] = rt(xx);
    }
    for (i = 1; i <= mm; i++) {
      cin >> xx >> yy;
      ex[i].first = rt(xx);
      ex[i].second = rt(yy);
    }
    for (i = 1; i <= nn; i++) a[i] = b[i] = col[a[i]];
    for (i = 1; i <= mm; i++) {
      ex[i] = make_pair(col[ex[i].first], col[ex[i].second]);
      b[++num] = ex[i].first;
      b[++num] = ex[i].second;
    }
    sort(a + 1, a + nn + 1, [&](int x, int y) { return dffn[x] < dffn[y]; });
    nn = unique(a + 1, a + nn + 1) - a - 1;
    sort(b + 1, b + num + 1, [&](int x, int y) { return dffn[x] < dffn[y]; });
    num = unique(b + 1, b + num + 1) - b - 1;
    build();
    solve(t);
  }
  return 0;
}
