#include <bits/stdc++.h>   using namespace std;   int read() {     char ch;     for (ch = getchar(); ch <  0  || ch >  9 ; ch = getchar())       ;     int x = ch -  0 ;     for (ch = getchar(); ch >=  0  && ch <=  9 ; ch = getchar())       x = x * 10 + ch -  0 ;     return x;   }   const int N = 3e5 + 5;   int n, m, q, p[N], u[N], v[N];   struct Graph {     int t[N << 1], nxt[N << 1], lst[N], l;     void add(int x, int y) {       t[++l] = y;       nxt[l] = lst[x];       lst[x] = l;     }     int n, dfn[N], low[N], sta[N], col[N], top, tot, id;     void init(int N) {       n = N;       l = 1;       tot = id = 0;       for (int i = 1; i <= n; i++) col[i] = low[i] = dfn[i] = lst[i] = 0;     }     void tarjan(int x, int y) {       dfn[x] = low[x] = ++tot;       sta[++top] = x;       for (int i = lst[x]; i; i = nxt[i]) {         if (i == y) continue;         if (!dfn[t[i]]) {           tarjan(t[i], i ^ 1);           low[x] = min(low[x], low[t[i]]);         } else           low[x] = min(low[x], dfn[t[i]]);       }       if (dfn[x] == low[x])         for (sta[top + 1] = 0, id++; sta[top + 1] != x; top--) col[sta[top]] = id;     }   } g1, g2;   struct Tree {     int t[N << 1], nxt[N << 1], lst[N], l;     void add(int x, int y) {       t[++l] = y;       nxt[l] = lst[x];       lst[x] = l;     }     int dfn[N], ed[N], dep[N], fa[N][19], tot;     void dfs(int x, int y) {       dfn[x] = ++tot;       fa[x][0] = y;       dep[x] = dep[y] + 1;       for (int i = lst[x]; i; i = nxt[i])         if (t[i] != y) dfs(t[i], x);       ed[x] = tot;     }     void init(int n) {       for (int i = 1; i <= n; i++)         if (!dfn[i]) dfs(i, 0);       for (int j = 1; j <= 18; j++)         for (int i = 1; i <= n; i++) fa[i][j] = fa[fa[i][j - 1]][j - 1];     }     int lca(int x, int y) {       if (dep[x] < dep[y]) swap(x, y);       for (int j = 18; j >= 0; j--)         if (dep[fa[x][j]] > dep[y]) x = fa[x][j];       x = dep[x] == dep[y] ? x : fa[x][0];       for (int j = 18; j >= 0; j--)         if (fa[x][j] != fa[y][j]) x = fa[x][j], y = fa[y][j];       return x == y ? x : fa[x][0];     }   } t;   bool cmp(int x, int y) { return t.dfn[x] < t.dfn[y]; }   int sta[N], pr[N], id[N], sz, top;   vector<int> pt;   void build() {     sort(pt.begin(), pt.end(), cmp);     sz = pt.size();     for (int i = 1; i <= sz - 1; i++) {       int x = t.lca(pt[i], pt[i - 1]);       if (x) pt.push_back(x);     }     sort(pt.begin(), pt.end(), cmp);     sz = unique(pt.begin(), pt.end()) - pt.begin();     while (pt.size() > sz) pt.pop_back();     for (int i = 0; i <= sz - 1; i++) pr[pt[i]] = 0;     top = 0;     for (int i = 0; i < sz; i++) {       for (; top && t.ed[sta[top]] < t.dfn[pt[i]]; top--)         ;       if (top) pr[pt[i]] = sta[top];       sta[++top] = pt[i];     }     g2.init(sz);     for (int i = 0; i <= sz - 1; i++) id[pt[i]] = i + 1;     for (int i = 0; i <= sz - 1; i++) {       int x = id[pr[pt[i]]], y = i + 1;       if (x) g2.add(x, y), g2.add(y, x);     }   }   int main() {     n = read();     m = read();     q = read();     g1.init(n);     for (int i = 1; i <= m; i++) {       u[i] = read();       v[i] = read();       g1.add(u[i], v[i]);       g1.add(v[i], u[i]);     }     for (int i = 1; i <= n; i++)       if (!g1.dfn[i]) g1.tarjan(i, 0);     for (int i = 1; i <= m; i++) {       int x = g1.col[u[i]], y = g1.col[v[i]];       if (x != y) t.add(x, y), t.add(y, x);     }     t.init(g1.id);     int cnt = 0;     for (int ty = 1; ty <= q; ty++) {       int nn = read(), mm = read();       pt.clear();       for (int i = 1; i <= nn; i++) {         p[i] = g1.col[(read() + cnt + n - 1) % n + 1];         pt.push_back(p[i]);       }       for (int i = 1; i <= mm; i++) {         u[i] = g1.col[(read() + cnt + n - 1) % n + 1];         v[i] = g1.col[(read() + cnt + n - 1) % n + 1];         pt.push_back(u[i]);         pt.push_back(v[i]);       }       build();       for (int i = 1; i <= mm; i++) {         int x = id[u[i]], y = id[v[i]];         if (x != y) g2.add(x, y), g2.add(y, x);       }       for (int i = 1; i <= sz; i++)         if (!g2.dfn[i]) g2.tarjan(i, 0);       bool ok = 1;       for (int i = 2; i <= nn; i++)         if (g2.col[id[p[i]]] != g2.col[id[p[1]]]) {           ok = 0;           break;         }       if (ok) {         puts( YES );         (cnt += ty) %= n;       } else         puts( NO );     }     return 0;   }   