#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  int f = 0;
  x = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar()) f |= (ch == '-');
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  if (f) x = -x;
}
int read() {
  int x;
  read(x);
  return x;
}
int n, m, Q, R;
void Read(int &x) {
  read(x), x = (x + R) % n;
  if (x == 0) x = n;
}
const int N = 1000005;
namespace G {
int dfn[N], low[N], st[N], bel[N];
int n, clk, cnt, top;
vector<int> e[N];
void init(int _n) {
  for (int i = (1); i <= (n); i++) dfn[i] = low[i] = bel[i] = 0;
  for (int i = (1); i <= (n); i++) e[i].clear();
  n = _n, clk = cnt = top = 0;
}
void add(int u, int v) { e[u].push_back(v), e[v].push_back(u); }
void tarjan(int u, int fa) {
  dfn[u] = low[u] = ++clk, st[++top] = u;
  for (auto v : e[u])
    if (v != fa) {
      if (!dfn[v]) {
        tarjan(v, u);
        low[u] = min(low[u], low[v]);
      } else if (!bel[v])
        low[u] = min(low[u], dfn[v]);
    } else
      fa = 0;
  if (low[u] != dfn[u]) return;
  ++cnt;
  while (st[top] != u) bel[st[top--]] = cnt;
  bel[st[top--]] = cnt;
}
vector<pair<int, int> > doit() {
  vector<pair<int, int> > res;
  for (int u = (1); u <= (n); u++)
    if (!dfn[u]) tarjan(u, 0);
  for (int u = (1); u <= (n); u++)
    for (auto v : e[u])
      if (bel[u] != bel[v] && bel[u] < bel[v])
        res.push_back(make_pair(bel[u], bel[v]));
  return res;
}
void init(vector<int> &U) {
  for (auto u : U) dfn[u] = low[u] = bel[u] = 0;
  for (auto u : U) e[u].clear();
  clk = cnt = top = 0;
}
void solve(vector<int> &U) {
  for (auto u : U)
    if (!dfn[u]) tarjan(u, 0);
}
}  // namespace G
namespace T {
int fa[N][20], d[N], dfn[N], bel[N], n, clk;
vector<int> e[N], sp;
inline int lca(int a, int b) {
  if (d[a] < d[b]) swap(a, b);
  for (int i = (19); i >= (0); i--)
    if (d[fa[a][i]] >= d[b]) a = fa[a][i];
  if (a == b) return a;
  for (int i = (19); i >= (0); i--)
    if (fa[a][i] != fa[b][i]) a = fa[a][i], b = fa[b][i];
  return fa[a][0];
}
void dfs(int u, int pa) {
  fa[u][0] = pa, dfn[u] = ++clk;
  for (int i = (1); i <= (19); i++) fa[u][i] = fa[fa[u][i - 1]][i - 1];
  for (auto v : e[u])
    if (v != pa) d[v] = d[u] + 1, dfs(v, u);
}
int mark[N];
void Mark(int u) {
  mark[u] = 1;
  for (auto v : e[u])
    if (v != n && !mark[v]) Mark(v);
}
void build(vector<pair<int, int> > E) {
  n = G::cnt + 1;
  for (auto pi : E)
    e[pi.first].push_back(pi.second), e[pi.second].push_back(pi.first);
  for (int u = (1); u <= (n - 1); u++)
    if (!mark[u]) {
      e[n].push_back(u), e[u].push_back(n);
      Mark(u);
    }
  d[n] = 1, dfs(n, 0);
}
vector<pair<int, int> > EE;
inline bool cmp(int a, int b) { return dfn[a] < dfn[b]; }
int f[N], stk[N], top;
vector<int> now;
void push() {
  stk[top = 1] = n, now.clear();
  sort(sp.begin(), sp.end(), cmp);
  for (int i = (0); i < (sp.size()); i++)
    if (!i || sp[i] != sp[i - 1]) {
      int u = sp[i], v;
      while (top >= 2 && d[lca(stk[top], u)] < d[stk[top - 1]])
        f[stk[top]] = stk[top - 1], top--;
      if (top >= 2 && (v = lca(stk[top], u)) != stk[top]) {
        f[stk[top]] = v, top--;
        if (stk[top] != v) stk[++top] = v, now.push_back(v);
      }
      if (stk[top] != u) stk[++top] = u, now.push_back(u);
    }
  while (top >= 2) f[stk[top]] = stk[top - 1], top--;
  G::init(now);
  for (auto u : now)
    if (f[u] != n) G::add(u, f[u]);
  for (auto p : EE) G::add(p.first, p.second);
  G::solve(now);
}
int tim;
int solve() {
  int t = read(), K = read(), u, v, x;
  vector<int> V;
  sp.clear(), EE.clear();
  while (t--) Read(x), V.push_back(bel[x]), sp.push_back(bel[x]);
  while (K--) {
    Read(u), Read(v);
    sp.push_back(bel[u]), sp.push_back(bel[v]);
    EE.push_back(make_pair(bel[u], bel[v]));
  }
  push();
  for (int i = 0; i + 1 < V.size(); i++)
    if (G::bel[V[i]] != G::bel[V[i + 1]]) return 0;
  return 1;
}
}  // namespace T
int main() {
  n = read(), m = read(), Q = read();
  G::init(n);
  for (int i = (1); i <= (m); i++) G::add(read(), read());
  T::build(G::doit());
  for (int i = (1); i <= (n); i++) T::bel[i] = G::bel[i];
  int owo = 0;
  while (Q--) {
    int res = T::solve();
    ++owo, R = (R + res * owo) % n;
    puts(res ? "YES" : "NO");
  }
  return 0;
}
