#include <bits/stdc++.h>   using namespace std;   const int N = 300005;   int n, m, q;   struct Graph {     struct Edge {       int to, next;     } edge[N << 1];     int head[N], cnt;     Graph() {       memset(head, 0, sizeof(head));       cnt = 1;       return;     }     void add_edge(int u, int v) {       if (u == 0 || v == 0) return;       cnt++;       edge[cnt].to = v;       edge[cnt].next = head[u];       head[u] = cnt;       return;     }   };   Graph G1;   int dfn1[N], low1[N], Index1;   stack<int> s1;   int bel1[N], tot1;   void tarjan1(int u, int pre) {     dfn1[u] = low1[u] = ++Index1;     s1.push(u);     for (int i = G1.head[u]; i; i = G1.edge[i].next) {       int v = G1.edge[i].to;       if ((i ^ 1) == pre) continue;       if (!dfn1[v]) {         tarjan1(v, i);         low1[u] = min(low1[u], low1[v]);       } else         low1[u] = min(low1[u], dfn1[v]);     }     if (dfn1[u] == low1[u]) {       tot1++;       while (s1.top() != u) {         bel1[s1.top()] = tot1;         s1.pop();       }       bel1[u] = tot1;       s1.pop();       return;     }     return;   }   vector<int> G[N];   int f[N][20], dep[N];   int dfn[N], Index;   void dfs(int u, int father) {     dfn[u] = ++Index;     dep[u] = dep[father] + 1;     f[u][0] = father;     for (int i = 1; (1 << i) <= n; i++) f[u][i] = f[f[u][i - 1]][i - 1];     for (int v : G[u]) {       if (v == father) continue;       dfs(v, u);     }     return;   }   int LCA(int u, int v) {     if (dep[u] < dep[v]) swap(u, v);     for (int i = log2(n); i >= 0; i--)       if (dep[f[u][i]] >= dep[v]) u = f[u][i];     if (u == v) return u;     for (int i = log2(n); i >= 0; i--)       if (f[u][i] != f[v][i]) u = f[u][i], v = f[v][i];     return f[u][0];   }   int s[N << 1], top;   Graph G2;   vector<int> pos;   void ins(int u) {     int z = LCA(u, s[top]);     pos.push_back(u);     if (z == s[top])       s[++top] = u;     else {       pos.push_back(z);       while (top >= 2 && dep[s[top - 1]] > dep[z]) {         if (s[top - 1] != s[top])           G2.add_edge(s[top - 1], s[top]), G2.add_edge(s[top], s[top - 1]);         top--;       }       if (top) {         if (z != s[top]) G2.add_edge(z, s[top]), G2.add_edge(s[top], z);         top--;       }       s[++top] = z;       s[++top] = u;     }     return;   }   bool cmp(int a, int b) { return dfn[a] < dfn[b]; }   void build(vector<int>& k) {     sort(k.begin(), k.end());     k.erase(unique(k.begin(), k.end()), k.end());     sort(k.begin(), k.end(), cmp);     top = 0;     s[++top] = 0;     for (int x : k)       if (x != 0) ins(x);     while (top >= 2) {       if (s[top - 1] != s[top])         G2.add_edge(s[top - 1], s[top]), G2.add_edge(s[top], s[top - 1]);       top--;     }     sort(pos.begin(), pos.end());     pos.erase(unique(pos.begin(), pos.end()), pos.end());     return;   }   int dfn2[N], low2[N], Index2;   stack<int> s2;   int bel2[N], tot2;   void tarjan2(int u, int pre) {     dfn2[u] = low2[u] = ++Index2;     s2.push(u);     for (int i = G2.head[u]; i; i = G2.edge[i].next) {       int v = G2.edge[i].to;       if ((i ^ 1) == pre) continue;       if (!dfn2[v]) {         tarjan2(v, i);         low2[u] = min(low2[u], low2[v]);       } else         low2[u] = min(low2[u], dfn2[v]);     }     if (dfn2[u] == low2[u]) {       tot2++;       while (s2.top() != u) {         bel2[s2.top()] = tot2;         s2.pop();       }       bel2[u] = tot2;       s2.pop();       return;     }     return;   }   int x[N];   long long R;   int rotate(int element) {     element = (element + R) % n;     if (element == 0) {       element = n;     }     return element;   }   void clear() {     for (int u : pos) {       G2.head[u] = 0;       dfn2[u] = low2[u] = 0;       bel2[u] = 0;     }     pos.clear();     return;   }   int Case = 0;   void solve() {     Case++;     int ni, mi;     scanf( %d%d , &ni, &mi);     vector<int> k;     for (int i = 1; i <= ni; i++) {       scanf( %d , &x[i]);       x[i] = rotate(x[i]);       x[i] = bel1[x[i]];       k.push_back(x[i]);     }     G2.cnt = 1;     for (int i = 1; i <= mi; i++) {       int x, y;       scanf( %d%d , &x, &y);       x = rotate(x), y = rotate(y);       x = bel1[x], y = bel1[y];       if (x == y) continue;       G2.add_edge(x, y);       G2.add_edge(y, x);       k.push_back(x), k.push_back(y);     }     build(k);     Index2 = tot2 = 0;     while (!s2.empty()) s2.pop();     for (int u : pos)       if (!dfn2[u]) tarjan2(u, 0);     for (int i = 2; i <= ni; i++)       if (bel2[x[i]] != bel2[x[i - 1]]) {         printf( NO n );         clear();         return;       }     printf( YES n );     R += Case;     clear();     return;   }   int main() {     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d%d , &x, &y);       G1.add_edge(x, y);       G1.add_edge(y, x);     }     for (int i = 1; i <= n; i++)       if (!dfn1[i]) tarjan1(i, 0);     for (int u = 1; u <= n; u++)       for (int i = G1.head[u]; i; i = G1.edge[i].next) {         int v = G1.edge[i].to;         int x = bel1[u], y = bel1[v];         if (x < y) G[x].push_back(y), G[y].push_back(x);       }     for (int i = 1; i <= tot1; i++)       if (!dep[i]) dfs(i, 0);     while (q--) solve();     return 0;   }   