#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
char buf[1 << 23], *ps = buf, *pt = buf, pbuf[1 << 23], *pp = pbuf;
#define getchar() (ps == pt && (pt = (ps = buf) + fread(buf, 1, 1 << 23, stdin), ps == pt) ? EOF : *ps++)
int read(){
	register int x = 0;
	register char f = 1, ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f ^= 1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
	return f ? x : -x;
}
const int N = 300005;
int n, m, q, X[N], Y[N], nn, Col[N], cnt, col[N];
int edge, to[N << 1], pr[N << 1], hd[N];
void addedge(int u, int v){
	to[edge] = v, pr[edge] = hd[u], hd[u] = edge++;
}
namespace contract{
	int idx, dfn[N], low[N], top, sta[N], vis[N];
	void tarjan(int u, int fe = -1){
		dfn[u] = low[u] = ++idx, sta[++top] = u, vis[u] = 1;
		for (register int i = hd[u], v; ~i; i = pr[i]){
			if (!dfn[v = to[i]] && v) tarjan(v, i), low[u] = std :: min(low[u], low[v]);
			else if ((i ^ 1) != fe) low[u] = std :: min(low[u], dfn[v]);
		}
		if (dfn[u] == low[u]){
			sta[top + 1] = -1, ++cnt;
			while (sta[top + 1] != u) col[sta[top]] = cnt, --top;
		}
	}
	void Main(int n, int *p){
		idx = top = cnt = 0;
		for (register int i = 1; i <= n; ++i) dfn[p[i]] = 0;
		for (register int i = 1; i <= n; ++i)
			if (!dfn[p[i]] && p[i]) tarjan(p[i]);
	}
}
namespace tree{
	int idx, dfn[N], dep[N], fa[N][19];
	void dfs(int u){
		dfn[u] = ++idx, dep[u] = dep[fa[u][0]] + 1;
		for (register int i = 1; i <= 18; ++i) fa[u][i] = fa[fa[u][i - 1]][i - 1];
		for (register int i = hd[u], v; ~i; i = pr[i])
			if ((v = to[i]) != fa[u][0]) fa[v][0] = u, dfs(v);
	}
	void init(){
		idx = 0;
		for (register int i = 1; i <= nn; ++i) if (!dfn[i]) dfs(i);
	}
	int LCA(int u, int v){
		if (dep[u] < dep[v]) std :: swap(u, v);
		for (register int i = 18; ~i; --i)
			if (dep[fa[u][i]] >= dep[v]) u = fa[u][i];
		if (u == v) return u;
		for (register int i = 18; ~i; --i)
			if (fa[u][i] != fa[v][i]) u = fa[u][i], v = fa[v][i];
		return fa[u][0];
	}
}
using tree :: dfn;
using tree :: LCA;
int top, sta[N], k, p[N * 3], vis[N], tot, id[N];
void insert(int u){
	if (!top) return sta[++top] = u, void(0);
	int x = sta[top], lca = LCA(x, u), y;
	if (lca == x) return sta[++top] = u, void(0);
	while (top > 1 && dfn[y = sta[top - 1]] > dfn[lca])
		addedge(x, y), addedge(y, x), x = sta[--top];
	addedge(x, lca), addedge(lca, x), --top;
	if (!top || sta[top] != lca) sta[++top] = lca;
	sta[++top] = u;
}
void get_nodes(int u){
	vis[u] = 1, id[++tot] = u;
	for (register int i = hd[u], v; ~i; i = pr[i])
		if (!vis[v = to[i]]) get_nodes(v);
}
int main(){
	n = read(), m = read(), q = read();
	for (register int i = 1; i <= n; ++i) hd[i] = -1, id[i] = i;
	for (register int i = 1; i <= m; ++i)
		X[i] = read(), Y[i] = read(), addedge(X[i], Y[i]), addedge(Y[i], X[i]);
	contract :: Main(n, id);
	for (register int i = 1; i <= n; ++i) Col[i] = col[i];
	nn = cnt, edge = 0;
	for (register int i = 1; i <= nn; ++i) hd[i] = -1;
	for (register int i = 1; i <= m; ++i)
		if (Col[X[i]] != Col[Y[i]]) addedge(Col[X[i]], Col[Y[i]]), addedge(Col[Y[i]], Col[X[i]]);
	tree :: init(), edge = 0;
	for (register int i = 1; i <= nn; ++i) hd[i] = -1;
	int R = 0;
	for (register int T = 1; T <= q; ++T){
		k = read();
		int dm = read(), x, y;
		for (register int i = 1; i <= k; ++i) p[i] = Col[(read() + R - 1) % n + 1];
		for (register int i = 1; i <= dm; ++i){
			x = Col[(read() + R - 1) % n + 1], y = Col[(read() + R - 1) % n + 1];
			addedge(x, y), addedge(y, x), p[++k] = x, p[++k] = y;
		}
		std :: sort(p + 1, p + 1 + k, [=](int u, int v){
			return dfn[u] < dfn[v];
		});
		k = std :: unique(p + 1, p + 1 + k) - p - 1;
		top = 0;
		for (register int i = 1; i <= k; ++i) insert(p[i]);
		while (top > 1) x = sta[top], y = sta[top - 1], addedge(x, y), addedge(y, x), --top;
		tot = 0, get_nodes(sta[1]);
		contract :: Main(tot, id);
		if (cnt == 1) R = (R + T) % n, puts("YES");
		else puts("NO");
		edge = 0, hd[0] = -1;
		for (register int i = 1; i <= tot; ++i) hd[id[i]] = -1, vis[id[i]] = 0;
	}
}


#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
char buf[1 << 23], *ps = buf, *pt = buf, pbuf[1 << 23], *pp = pbuf;
#define getchar() (ps == pt && (pt = (ps = buf) + fread(buf, 1, 1 << 23, stdin), ps == pt) ? EOF : *ps++)
int read(){
	register int x = 0;
	register char f = 1, ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f ^= 1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
	return f ? x : -x;
}
const int N = 300005;
int n, m, q, X[N], Y[N], nn, Col[N], cnt, col[N];
int edge, to[N << 1], pr[N << 1], hd[N];
void addedge(int u, int v){
	if (v == 0) return;
	to[edge] = v, pr[edge] = hd[u], hd[u] = edge++;
}
namespace contract{
	int idx, dfn[N], low[N], top, sta[N], vis[N];
	void tarjan(int u, int fe = -1){
		dfn[u] = low[u] = ++idx, sta[++top] = u, vis[u] = 1;
		for (register int i = hd[u], v; ~i; i = pr[i]){
			if (!dfn[v = to[i]]) tarjan(v, i), low[u] = std :: min(low[u], low[v]);
			else if ((i ^ 1) != fe) low[u] = std :: min(low[u], dfn[v]);
		}
		if (dfn[u] == low[u]){
			sta[top + 1] = -1, ++cnt;
			while (sta[top + 1] != u) col[sta[top]] = cnt, --top;
		}
	}
	void Main(int n, int *p){
		idx = top = cnt = 0;
		for (register int i = 1; i <= n; ++i) dfn[p[i]] = 0;
		for (register int i = 1; i <= n; ++i) if (!dfn[p[i]]) tarjan(p[i]);
	}
}
namespace tree{
	int idx, dfn[N], dep[N], fa[N][19];
	void dfs(int u){
		dfn[u] = ++idx, dep[u] = dep[fa[u][0]] + 1;
		for (register int i = 1; i <= 18; ++i) fa[u][i] = fa[fa[u][i - 1]][i - 1];
		for (register int i = hd[u], v; ~i; i = pr[i])
			if ((v = to[i]) != fa[u][0]) fa[v][0] = u, dfs(v);
	}
	void init(){
		idx = 0;
		for (register int i = 1; i <= nn; ++i) if (!dfn[i]) dfs(i);
	}
	int LCA(int u, int v){
		if (dep[u] < dep[v]) std :: swap(u, v);
		for (register int i = 18; ~i; --i)
			if (dep[fa[u][i]] >= dep[v]) u = fa[u][i];
		if (u == v) return u;
		for (register int i = 18; ~i; --i)
			if (fa[u][i] != fa[v][i]) u = fa[u][i], v = fa[v][i];
		return fa[u][0];
	}
}
using tree :: dfn;
using tree :: LCA;
int top, sta[N], k, p[N * 3], vis[N], tot, id[N];
void insert(int u){
	if (!top) return sta[++top] = u, void(0);
	int x = sta[top], lca = LCA(x, u), y;
	if (lca == x) return sta[++top] = u, void(0);
	while (top > 1 && dfn[y = sta[top - 1]] > dfn[lca])
		addedge(x, y), addedge(y, x), x = sta[--top];
	addedge(x, lca), addedge(lca, x), --top;
	if (!top || sta[top] != lca) sta[++top] = lca;
	sta[++top] = u;
}
void get_nodes(int u){
	if (u) vis[u] = 1, id[++tot] = u;
	for (register int i = hd[u], v; ~i; i = pr[i])
		if (!vis[v = to[i]]) get_nodes(v);
}
int main(){
	n = read(), m = read(), q = read();
	for (register int i = 1; i <= n; ++i) hd[i] = -1, id[i] = i;
	for (register int i = 1; i <= m; ++i)
		X[i] = read(), Y[i] = read(), addedge(X[i], Y[i]), addedge(Y[i], X[i]);
	contract :: Main(n, id);
	for (register int i = 1; i <= n; ++i) Col[i] = col[i];
	nn = cnt, edge = 0;
	for (register int i = 1; i <= nn; ++i) hd[i] = -1;
	for (register int i = 1; i <= m; ++i)
		if (Col[X[i]] != Col[Y[i]]) addedge(Col[X[i]], Col[Y[i]]), addedge(Col[Y[i]], Col[X[i]]);
	tree :: init(), edge = 0;
	for (register int i = 1; i <= nn; ++i) hd[i] = -1;
	int R = 0;
	for (register int T = 1; T <= q; ++T){
		k = read();
		int dm = read(), x, y;
		for (register int i = 1; i <= k; ++i) p[i] = Col[(read() + R - 1) % n + 1];
		for (register int i = 1; i <= dm; ++i){
			x = Col[(read() + R - 1) % n + 1], y = Col[(read() + R - 1) % n + 1];
			addedge(x, y), addedge(y, x), p[++k] = x, p[++k] = y;
		}
		std :: sort(p + 1, p + 1 + k, [=](int u, int v){
			return dfn[u] < dfn[v];
		});
		k = std :: unique(p + 1, p + 1 + k) - p - 1;
		top = 0;
		for (register int i = 1; i <= k; ++i) insert(p[i]);
		while (top > 1) x = sta[top], y = sta[top - 1], addedge(x, y), addedge(y, x), --top;
		tot = 0, get_nodes(sta[1]);
		contract :: Main(tot, id);
		if (cnt == 1) R = (R + T) % n, puts("YES");
		else puts("NO");
		edge = 0;
		for (register int i = 1; i <= tot; ++i) hd[id[i]] = -1, vis[id[i]] = 0;
	}
}


#include<bits/stdc++.h>
using namespace std;
const int N = 6e5+100;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)
#define pb push_back

struct edge{
   int head[N],nxt[N],to[N],tot;
   void init(){
      memset(head,0,sizeof head);
      tot = 1;
   }
   inline void add_edge(int x,int y){
      to[++tot] = y; nxt[tot] = head[x]; head[x] = tot;
      to[++tot] = x; nxt[tot] = head[y]; head[y] = tot;
   }
}e1,e2,e3;

stack<int> stk;
int bel[N],cnt;
int dfn[N],low[N],tot;
int res[N];
void tarjan(int x,edge *e,int en,int *bel1){
   dfn[x] = ++tot; low[x] = tot; stk.push(x);
   for(int i = e->head[x];i;i = e->nxt[i]){
      if(i == en)continue ;
      int y = e->to[i];
      if(!dfn[y]){
         tarjan(y,e,i^1,bel1); low[x] = min(low[x],low[y]);
      } else low[x] = min(low[x],dfn[y]);
   }

   if(low[x] >= dfn[x]){
      ++cnt;
      int curx;
      do{
         curx = stk.top(); stk.pop();
         bel1[curx] = cnt;
      } while(curx != x);
   }
   return ;
}

stack<int> stk2;

int st[N][21],dep[N],dfn2[N],cnt2;
void dfs2(int x,int fa){
   dfn2[x] = ++cnt2;
   st[x][0] = fa; dep[x] = dep[fa]+1;
   fr(i,1,20)st[x][i] = st[st[x][i-1]][i-1];
   for(int i = e2.head[x];i;i = e2.nxt[i]){
      int y = e2.to[i];
      if(y == fa)continue ;
      dfs2(y,x);
   }
}

inline int cmp(int x,int y){
   return dfn2[x] < dfn2[y];
}

inline int lca(int x,int y){
   if(dep[x] < dep[y])swap(x,y);
   nfr(i,20,0){
      if(dep[st[x][i]] >= dep[y])x = st[x][i];
   }
   if(x == y)return x;
   nfr(i,20,0){
      if(st[x][i] != st[y][i])x = st[x][i],y = st[y][i];
   }
   return st[x][0];
}

int xi[N],yi[N];

int n,m,q;
vector<int> v1,clr;
int v2[N],vcnt;
bool lstans;

int main(){
   scanf("%d%d%d",&n,&m,&q);

   e1.init();
   fr(i,1,m){
      int x,y; scanf("%d%d",&x,&y);
      e1.add_edge(x,y);
   }

   fr(i,1,n)
      if(!dfn[i])tarjan(i,&e1,0,bel);

   e2.init();
   fr(i,1,n){
      for(int j = e1.head[i];j;j = e1.nxt[j]){
         int y = e1.to[j];
         if(i < y && bel[i] != bel[y])e2.add_edge(bel[i],bel[y]);
      }
   }

   dep[0] = 0;
   fr(i,1,cnt){
      if(!dep[i])dfs2(i,0);
   }

   lstans = 0;
   memset(dfn,0,sizeof dfn);
   memset(low,0,sizeof low);
   memset(res,0,sizeof res);

   fr(t,1,q){
      int ni,mi;
      scanf("%d%d",&ni,&mi);

      vcnt = 0;
      v1.clear();
      fr(i,1,ni){
         int x; scanf("%d",&x);
         x = (x+lstans-1)%n+1;
         v1.pb(bel[x]); v2[++vcnt] = bel[x];
      }

      fr(i,1,mi){
         scanf("%d%d",&xi[i],&yi[i]);
         xi[i] = (xi[i]+lstans-1)%n+1; yi[i] = (yi[i]+lstans-1)%n+1;
         v2[++vcnt] = bel[xi[i]]; v2[++vcnt] = bel[yi[i]];
      }

      sort(v2+1,v2+vcnt+1,cmp);
      int nsiz = unique(v2+1,v2+vcnt+1)-v2-1;
      fr(i,1,nsiz)clr.pb(v2[i]);

      e3.tot = 1;

      stk2.push(0);
      fr(i,1,nsiz){
         int w = stk2.top();
         int z = lca(v2[i],w); clr.pb(z);
         if(z == w)stk2.push(v2[i]);
         else {
            while(dfn2[stk2.top()] > dfn2[z]){
               int cur = stk2.top(); stk2.pop();
               if(stk2.top() != 0)e3.add_edge(stk2.top(),cur);
            }
            if(stk2.top() == z){
               stk2.push(v2[i]);
            } else {
               stk2.push(z); stk2.push(v2[i]);
            }
         }
      }

      fr(i,1,mi){
         if(bel[xi[i]] != bel[yi[i]]){
            e3.add_edge(bel[xi[i]],bel[yi[i]]);
         }
      }

      while(!stk2.empty()){
         int cur = stk2.top(); stk2.pop();
         if(cur == 0)break;
         if(stk2.top() != 0){
            e3.add_edge(stk2.top(),cur);
         }
      }

      tarjan(v1[0],&e3,0,res);

      lstans = true;
      fr(i,1,(int)v1.size()-1){
         lstans &= res[v1[i]] == res[v1[0]];
      }
      if(lstans)puts("YES");
      else puts("NO");

      fr(i,0,(int)clr.size()-1)res[clr[i]] = e3.head[clr[i]] =
         dfn[clr[i]] = low[clr[i]] = 0;
   }
}


#include<bits/stdc++.h>
using namespace std;
const int N = 6e5+100;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)
#define pb push_back

struct edge{
   int head[N],nxt[N],to[N],tot;
   void init(){
      memset(head,0,sizeof head);
      tot = 1;
   }
   inline void add_edge(int x,int y){
      to[++tot] = y; nxt[tot] = head[x]; head[x] = tot;
      to[++tot] = x; nxt[tot] = head[y]; head[y] = tot;
   }
}e1,e2,e3;

stack<int> stk;
int bel[N],cnt;
int dfn[N],low[N],tot;
int res[N];
void tarjan(int x,edge *e,int en,int *bel1){
   dfn[x] = ++tot; low[x] = tot; stk.push(x);
   for(int i = e->head[x];i;i = e->nxt[i]){
      if(i == en)continue ;
      int y = e->to[i];
      if(!dfn[y]){
         tarjan(y,e,i^1,bel1); low[x] = min(low[x],low[y]);
      } else low[x] = min(low[x],dfn[y]);
   }

   if(low[x] >= dfn[x]){
      ++cnt;
      int curx;
      do{
         curx = stk.top(); stk.pop();
         bel1[curx] = cnt;
      } while(curx != x);
   }
   return ;
}

stack<int> stk2;

int st[N][21],dep[N],dfn2[N],cnt2;
void dfs2(int x,int fa){
   dfn2[x] = ++cnt2;
   st[x][0] = fa; dep[x] = dep[fa]+1;
   fr(i,1,20)st[x][i] = st[st[x][i-1]][i-1];
   for(int i = e2.head[x];i;i = e2.nxt[i]){
      int y = e2.to[i];
      if(y == fa)continue ;
      dfs2(y,x);
   }
}

inline int cmp(int x,int y){
   return dfn2[x] < dfn2[y];
}

inline int lca(int x,int y){
   if(dep[x] < dep[y])swap(x,y);
   nfr(i,20,0){
      if(dep[st[x][i]] >= dep[y])x = st[x][i];
   }
   if(x == y)return x;
   nfr(i,20,0){
      if(st[x][i] != st[y][i])x = st[x][i],y = st[y][i];
   }
   return st[x][0];
}

int xi[N],yi[N];

int n,m,q;
vector<int> v1,clr;
int v2[N],vcnt;
int lstans;

int main(){
   scanf("%d%d%d",&n,&m,&q);

   e1.init();
   fr(i,1,m){
      int x,y; scanf("%d%d",&x,&y);
      e1.add_edge(x,y);
   }

   fr(i,1,n)
      if(!dfn[i])tarjan(i,&e1,0,bel);

   e2.init();
   fr(i,1,n){
      for(int j = e1.head[i];j;j = e1.nxt[j]){
         int y = e1.to[j];
         if(i < y && bel[i] != bel[y])e2.add_edge(bel[i],bel[y]);
      }
   }

   dep[0] = 0;
   fr(i,1,cnt){
      if(!dep[i])dfs2(i,0);
   }

   lstans = 0;
   memset(dfn,0,sizeof dfn);
   memset(low,0,sizeof low);
   memset(res,0,sizeof res);

   fr(t,1,q){
      int ni,mi;
      scanf("%d%d",&ni,&mi);

      vcnt = 0;
      v1.clear();
      fr(i,1,ni){
         int x; scanf("%d",&x);
         x = (x+lstans-1)%n+1;
         v1.pb(bel[x]); v2[++vcnt] = bel[x];
      }

      fr(i,1,mi){
         scanf("%d%d",&xi[i],&yi[i]);
         xi[i] = (xi[i]+lstans-1)%n+1; yi[i] = (yi[i]+lstans-1)%n+1;
         v2[++vcnt] = bel[xi[i]]; v2[++vcnt] = bel[yi[i]];
      }

      sort(v2+1,v2+vcnt+1,cmp);
      int nsiz = unique(v2+1,v2+vcnt+1)-v2-1;

      clr.clear();
      fr(i,1,nsiz)clr.pb(v2[i]);

      e3.tot = 1;

      stk2.push(0);
      fr(i,1,nsiz){
         int w = stk2.top();
         int z = lca(v2[i],w); clr.pb(z);
         if(z == w)stk2.push(v2[i]);
         else {
            while(dfn2[stk2.top()] > dfn2[z]){
               int cur = stk2.top(); stk2.pop();
               if(stk2.top() != 0)e3.add_edge(stk2.top(),cur);
            }
            if(stk2.top() == z){
               stk2.push(v2[i]);
            } else {
               stk2.push(z); stk2.push(v2[i]);
            }
         }
      }

      fr(i,1,mi){
         if(bel[xi[i]] != bel[yi[i]]){
            e3.add_edge(bel[xi[i]],bel[yi[i]]);
         }
      }

      while(!stk2.empty()){
         int cur = stk2.top(); stk2.pop();
         if(cur == 0)break;
         if(stk2.top() != 0){
            e3.add_edge(stk2.top(),cur);
         }
      }

      tarjan(v1[0],&e3,0,res);

      bool flag = true;
      fr(i,1,(int)v1.size()-1){
         flag &= res[v1[i]] == res[v1[0]];
      }
      if(flag)puts("YES"),lstans = (lstans+t)%n;
      else puts("NO");

      fr(i,0,(int)clr.size()-1)res[clr[i]] = e3.head[clr[i]] =
         dfn[clr[i]] = low[clr[i]] = 0;
   }
}


#include<bits/stdc++.h>
using namespace std;
const int N = 6e5+100;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)
#define pb push_back

struct edge{
   int head[N],nxt[N],to[N],tot;
   void init(){
      memset(head,0,sizeof head);
      tot = 1;
   }
   inline void add_edge(int x,int y){
      to[++tot] = y; nxt[tot] = head[x]; head[x] = tot;
      to[++tot] = x; nxt[tot] = head[y]; head[y] = tot;
   }
}e1,e2,e3;

stack<int> stk;
int bel[N],cnt;
int dfn[N],low[N],tot;
int res[N];
void tarjan(int x,edge *e,int en,int *bel1){
   dfn[x] = ++tot; low[x] = tot; stk.push(x);
   for(int i = e->head[x];i;i = e->nxt[i]){
      if(i == en)continue ;
      int y = e->to[i]; if(y == 0)continue ;
      if(!dfn[y]){
         tarjan(y,e,i^1,bel1); low[x] = min(low[x],low[y]);
      } else low[x] = min(low[x],dfn[y]);
   }

   if(low[x] >= dfn[x]){
      ++cnt;
      int curx;
      do{
         curx = stk.top(); stk.pop();
         bel1[curx] = cnt;
      } while(curx != x);
   }
   return ;
}

stack<int> stk2;

int st[N][21],dep[N],dfn2[N],cnt2;
void dfs2(int x,int fa){
   dfn2[x] = ++cnt2;
   st[x][0] = fa; dep[x] = dep[fa]+1;
   fr(i,1,20)st[x][i] = st[st[x][i-1]][i-1];
   for(int i = e2.head[x];i;i = e2.nxt[i]){
      int y = e2.to[i];
      if(y == fa)continue ;
      dfs2(y,x);
   }
}

inline int cmp(int x,int y){
   return dfn2[x] < dfn2[y];
}

inline int lca(int x,int y){
   if(dep[x] < dep[y])swap(x,y);
   nfr(i,20,0){
      if(dep[st[x][i]] >= dep[y])x = st[x][i];
   }
   if(x == y)return x;
   nfr(i,20,0){
      if(st[x][i] != st[y][i])x = st[x][i],y = st[y][i];
   }
   return st[x][0];
}

int xi[N],yi[N];

int n,m,q;
vector<int> v1,clr;
int v2[N],vcnt;
int lstans;

int main(){
   scanf("%d%d%d",&n,&m,&q);

   e1.init();
   fr(i,1,m){
      int x,y; scanf("%d%d",&x,&y);
      e1.add_edge(x,y);
   }

   fr(i,1,n)
      if(!dfn[i])tarjan(i,&e1,0,bel);

   e2.init();
   fr(i,1,n){
      for(int j = e1.head[i];j;j = e1.nxt[j]){
         int y = e1.to[j];
         if(i < y && bel[i] != bel[y])e2.add_edge(bel[i],bel[y]);
      }
   }

   dep[0] = 0;
   fr(i,1,cnt){
      if(!dep[i])dfs2(i,0);
   }

   lstans = 0;
   memset(dfn,0,sizeof dfn);
   memset(low,0,sizeof low);
   memset(res,0,sizeof res);

   fr(t,1,q){
      int ni,mi;
      scanf("%d%d",&ni,&mi);

      vcnt = 0;
      v1.clear();
      fr(i,1,ni){
         int x; scanf("%d",&x);
         x = (x+lstans-1)%n+1;
         v1.pb(bel[x]); v2[++vcnt] = bel[x];
      }

      fr(i,1,mi){
         scanf("%d%d",&xi[i],&yi[i]);
         xi[i] = (xi[i]+lstans-1)%n+1; yi[i] = (yi[i]+lstans-1)%n+1;
         v2[++vcnt] = bel[xi[i]]; v2[++vcnt] = bel[yi[i]];
      }

      sort(v2+1,v2+vcnt+1,cmp);
      int nsiz = unique(v2+1,v2+vcnt+1)-v2-1;

      clr.clear();
      fr(i,1,nsiz)clr.pb(v2[i]);

      e3.tot = 1;

      stk2.push(0);
      fr(i,1,nsiz){
         int w = stk2.top();
         int z = lca(v2[i],w); clr.pb(z);
         if(z == w)stk2.push(v2[i]);
         else {
            while(dfn2[stk2.top()] > dfn2[z]){
               int cur = stk2.top(); stk2.pop();
               if(dfn2[stk2.top()] > dfn2[z]){
                  e3.add_edge(stk2.top(),cur);
               } else {
                  e3.add_edge(z,cur);
               }
            }
            if(stk2.top() == z){
               stk2.push(v2[i]);
            } else {
               stk2.push(z); stk2.push(v2[i]);
            }
         }
      }

      fr(i,1,mi){
         if(bel[xi[i]] != bel[yi[i]]){
            e3.add_edge(bel[xi[i]],bel[yi[i]]);
         }
      }

      while(!stk2.empty()){
         int cur = stk2.top(); stk2.pop();
         if(cur == 0)break;
         if(stk2.top() != 0){
            e3.add_edge(stk2.top(),cur);
         }
      }

      tarjan(v1[0],&e3,0,res);

      bool flag = true;
      fr(i,1,(int)v1.size()-1){
         flag &= res[v1[i]] == res[v1[0]];
      }
      if(flag)puts("YES"),lstans = (lstans+t)%n;
      else puts("NO");

      fr(i,0,(int)clr.size()-1)res[clr[i]] = e3.head[clr[i]] =
         dfn[clr[i]] = low[clr[i]] = 0;
   }
}
/*
8 5 1
1 2
4 5
3 2
1 3
7 6
8 5
1 2 3 4 5 6 7 8
3 8
2 4
8 5
6 1
6 3
*/


#include<bits/stdc++.h>
using namespace std;
const int N = 6e5+100;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)
#define pb push_back

struct edge{
   int head[N],nxt[N],to[N],tot;
   void init(){
      memset(head,0,sizeof head);
      tot = 1;
   }
   inline void add_edge(int x,int y){
      to[++tot] = y; nxt[tot] = head[x]; head[x] = tot;
      to[++tot] = x; nxt[tot] = head[y]; head[y] = tot;
   }
}e1,e2,e3;

stack<int> stk;
int bel[N],cnt;
int dfn[N],low[N],tot;
int res[N];
void tarjan(int x,edge *e,int en,int *bel1){
   dfn[x] = ++tot; low[x] = tot; stk.push(x);
   for(int i = e->head[x];i;i = e->nxt[i]){
      if(i == en)continue ;
      int y = e->to[i];
      if(!dfn[y]){
         tarjan(y,e,i^1,bel1); low[x] = min(low[x],low[y]);
      } else low[x] = min(low[x],dfn[y]);
   }

   if(low[x] >= dfn[x]){
      ++cnt;
      int curx;
      do{
         curx = stk.top(); stk.pop();
         bel1[curx] = cnt;
      } while(curx != x);
   }
   return ;
}

stack<int> stk2;

int st[N][21],dep[N],dfn2[N],cnt2;
void dfs2(int x,int fa){
   dfn2[x] = ++cnt2;
   st[x][0] = fa; dep[x] = dep[fa]+1;
   fr(i,1,20)st[x][i] = st[st[x][i-1]][i-1];
   for(int i = e2.head[x];i;i = e2.nxt[i]){
      int y = e2.to[i];
      if(y == fa)continue ;
      dfs2(y,x);
   }
}

inline int cmp(int x,int y){
   return dfn2[x] < dfn2[y];
}

inline int lca(int x,int y){
   if(dep[x] < dep[y])swap(x,y);
   nfr(i,20,0){
      if(dep[st[x][i]] >= dep[y])x = st[x][i];
   }
   if(x == y)return x;
   nfr(i,20,0){
      if(st[x][i] != st[y][i])x = st[x][i],y = st[y][i];
   }
   return st[x][0];
}

int xi[N],yi[N];

int n,m,q;
vector<int> v1,clr;
int v2[N],vcnt;
int lstans;

int main(){
   scanf("%d%d%d",&n,&m,&q);

   e1.init();
   fr(i,1,m){
      int x,y; scanf("%d%d",&x,&y);
      e1.add_edge(x,y);
   }

   fr(i,1,n)
      if(!dfn[i])tarjan(i,&e1,0,bel);

   e2.init();
   fr(i,1,n){
      for(int j = e1.head[i];j;j = e1.nxt[j]){
         int y = e1.to[j];
         if(i < y && bel[i] != bel[y])e2.add_edge(bel[i],bel[y]);
      }
   }

   dep[0] = 0;
   fr(i,1,cnt){
      if(!dep[i])dfs2(i,0);
   }

   lstans = 0;
   memset(dfn,0,sizeof dfn);
   memset(low,0,sizeof low);
   memset(res,0,sizeof res);

   fr(t,1,q){
      int ni,mi;
      scanf("%d%d",&ni,&mi);

      vcnt = 0;
      v1.clear();
      fr(i,1,ni){
         int x; scanf("%d",&x);
         x = (x+lstans-1)%n+1;
         v1.pb(bel[x]); v2[++vcnt] = bel[x];
      }

      fr(i,1,mi){
         scanf("%d%d",&xi[i],&yi[i]);
         xi[i] = (xi[i]+lstans-1)%n+1; yi[i] = (yi[i]+lstans-1)%n+1;
         v2[++vcnt] = bel[xi[i]]; v2[++vcnt] = bel[yi[i]];
      }

      sort(v2+1,v2+vcnt+1,cmp);
      int nsiz = unique(v2+1,v2+vcnt+1)-v2-1;
      fr(i,1,nsiz)clr.pb(v2[i]);

      e3.tot = 1;

      stk2.push(0);
      fr(i,1,nsiz){
         int w = stk2.top();
         int z = lca(v2[i],w); clr.pb(z);
         if(z == w)stk2.push(v2[i]);
         else {
            while(dfn2[stk2.top()] > dfn2[z]){
               int cur = stk2.top(); stk2.pop();
               if(stk2.top() != 0)e3.add_edge(stk2.top(),cur);
            }
            if(stk2.top() == z){
               stk2.push(v2[i]);
            } else {
               stk2.push(z); stk2.push(v2[i]);
            }
         }
      }

      fr(i,1,mi){
         if(bel[xi[i]] != bel[yi[i]]){
            e3.add_edge(bel[xi[i]],bel[yi[i]]);
         }
      }

      while(!stk2.empty()){
         int cur = stk2.top(); stk2.pop();
         if(cur == 0)break;
         if(stk2.top() != 0){
            e3.add_edge(stk2.top(),cur);
         }
      }

      tarjan(v1[0],&e3,0,res);

      bool flag = true;
      fr(i,1,(int)v1.size()-1){
         flag &= res[v1[i]] == res[v1[0]];
      }
      if(flag)puts("YES"),++lstans;
      else puts("NO");

      fr(i,0,(int)clr.size()-1)res[clr[i]] = e3.head[clr[i]] =
         dfn[clr[i]] = low[clr[i]] = 0;
   }
}


#include<bits/stdc++.h>
using namespace std;
const int N = 6e5+100;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)
#define pb push_back

struct edge{
   int head[N],nxt[N],to[N],tot;
   void init(){
      memset(head,0,sizeof head);
      tot = 1;
   }
   inline void add_edge(int x,int y){
      to[++tot] = y; nxt[tot] = head[x]; head[x] = tot;
      to[++tot] = x; nxt[tot] = head[y]; head[y] = tot;
   }
}e1,e2,e3;

stack<int> stk;
int bel[N],cnt;
int dfn[N],low[N],tot;
int res[N];
void tarjan(int x,edge *e,int en,int *bel1){
   dfn[x] = ++tot; low[x] = tot; stk.push(x);
   for(int i = e->head[x];i;i = e->nxt[i]){
      if(i == en)continue ;
      int y = e->to[i];
      if(!dfn[y]){
         tarjan(y,e,i^1,bel1); low[x] = min(low[x],low[y]);
      } else low[x] = min(low[x],dfn[y]);
   }

   if(low[x] >= dfn[x]){
      ++cnt;
      int curx;
      do{
         curx = stk.top(); stk.pop();
         bel1[curx] = cnt;
      } while(curx != x);
   }
   return ;
}

stack<int> stk2;

int st[N][21],dep[N],dfn2[N],cnt2;
void dfs2(int x,int fa){
   dfn2[x] = ++cnt2;
   st[x][0] = fa; dep[x] = dep[fa]+1;
   fr(i,1,20)st[x][i] = st[st[x][i-1]][i-1];
   for(int i = e2.head[x];i;i = e2.nxt[i]){
      int y = e2.to[i];
      if(y == fa)continue ;
      dfs2(y,x);
   }
}

inline int cmp(int x,int y){
   return dfn2[x] < dfn2[y];
}

inline int lca(int x,int y){
   if(dep[x] < dep[y])swap(x,y);
   nfr(i,20,0){
      if(dep[st[x][i]] >= dep[y])x = st[x][i];
   }
   if(x == y)return x;
   nfr(i,20,0){
      if(st[x][i] != st[y][i])x = st[x][i],y = st[y][i];
   }
   return st[x][0];
}

int xi[N],yi[N];

int n,m,q;
vector<int> v1,clr;
int v2[N],vcnt;
int lstans;

int main(){
   scanf("%d%d%d",&n,&m,&q);

   e1.init();
   fr(i,1,m){
      int x,y; scanf("%d%d",&x,&y);
      e1.add_edge(x,y);
   }

   fr(i,1,n)
      if(!dfn[i])tarjan(i,&e1,0,bel);

   e2.init();
   fr(i,1,n){
      for(int j = e1.head[i];j;j = e1.nxt[j]){
         int y = e1.to[j];
         if(i < y && bel[i] != bel[y])e2.add_edge(bel[i],bel[y]);
      }
   }

   dep[0] = 0;
   fr(i,1,cnt){
      if(!dep[i])dfs2(i,0);
   }

   lstans = 0;
   memset(dfn,0,sizeof dfn);
   memset(low,0,sizeof low);
   memset(res,0,sizeof res);

   fr(t,1,q){
      int ni,mi;
      scanf("%d%d",&ni,&mi);

      vcnt = 0;
      v1.clear();
      fr(i,1,ni){
         int x; scanf("%d",&x);
         x = (x+lstans-1)%n+1;
         v1.pb(bel[x]); v2[++vcnt] = bel[x];
      }

      fr(i,1,mi){
         scanf("%d%d",&xi[i],&yi[i]);
         xi[i] = (xi[i]+lstans-1)%n+1; yi[i] = (yi[i]+lstans-1)%n+1;
         v2[++vcnt] = bel[xi[i]]; v2[++vcnt] = bel[yi[i]];
      }

      sort(v2+1,v2+vcnt+1,cmp);
      int nsiz = unique(v2+1,v2+vcnt+1)-v2-1;

      clr.clear();
      fr(i,1,nsiz)clr.pb(v2[i]);

      e3.tot = 1;

      stk2.push(0);
      fr(i,1,nsiz){
         int w = stk2.top();
         int z = lca(v2[i],w); clr.pb(z);
         if(z == w)stk2.push(v2[i]);
         else {
            while(dfn2[stk2.top()] > dfn2[z]){
               int cur = stk2.top(); stk2.pop();
               if(dfn2[stk2.top()] > dfn2[z]){
                  e3.add_edge(stk2.top(),cur);
               } else {
                  e3.add_edge(z,cur);
               }
            }
            if(stk2.top() == z){
               stk2.push(v2[i]);
            } else {
               stk2.push(z); stk2.push(v2[i]);
            }
         }
      }

      fr(i,1,mi){
         if(bel[xi[i]] != bel[yi[i]]){
            e3.add_edge(bel[xi[i]],bel[yi[i]]);
         }
      }

      while(!stk2.empty()){
         int cur = stk2.top(); stk2.pop();
         if(cur == 0)break;
         if(stk2.top() != 0){
            e3.add_edge(stk2.top(),cur);
         }
      }

      tarjan(v1[0],&e3,0,res);

      bool flag = true;
      fr(i,1,(int)v1.size()-1){
         flag &= res[v1[i]] == res[v1[0]];
      }
      if(flag)puts("YES"),lstans = (lstans+t)%n;
      else puts("NO");

      fr(i,0,(int)clr.size()-1)res[clr[i]] = e3.head[clr[i]] =
         dfn[clr[i]] = low[clr[i]] = 0;
   }
}


//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}
	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rda(I *a, int &n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rds(char *s, int &x) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (x = 0; c >= 33 && c <= 126; s[++x] = c, c = gc());
		s[x+1] = '\0';
	}
	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	inline void prints(string s) {
		int x = s.length();
		while (t < x) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rds;
using io::print;
using io::prints;

const int N = 3e5 + 7, M = 6e5 + 7;
int q, rt[N], f[N][21], d[N], dfn[N], tot, s[N], t;

struct Undirected_Gragh_edcc {
	int n, m, h[N], e[M*2], t[M*2], tot = 1, dfn[N], low[N], num;
	bool b[M*2];
	int c[N], dcc;
	vi bridge, ec[N];
	inline void add(int x, int y, int o = 1) {
		e[++tot] = y, t[tot] = h[x], h[x] = tot;
		if (o) add(y, x, 0);
	}
	void tarjan(int x, int f) {
//		dbg(x);
		dfn[x] = low[x] = ++num;
		for (int i = h[x]; i; i = t[i])
			if (i ^ f ^ 1) {
				int y = e[i];
	//			dbg(y);
				if (!dfn[y]) {
					tarjan(y, i), low[x] = min(low[x], low[y]);
					if (low[y] > dfn[x]) b[i] = b[i^1] = 1, bridge.pb(i);
				} else low[x] = min(low[x], dfn[y]);
			}
	}
	void dfs(int x) {
//		dbg(x), dbg(dcc);
		c[x] = dcc;
		for (int i = h[x]; i; i = t[i]) {
//			dbg(i);
			int y = e[i];
//			dbg(y);
			if (c[y] || b[i]) continue;
			dfs(y);
		}
	}
	inline void Bridge() {
		for (int i = 1; i <= n; i++)
			if (!dfn[i]) tarjan(i, 0);
//		for (int i = 1; i <= n; i++)
//			debug("dfn[%d] = %d, low = %d\n", i, dfn[i], low[i]);
	}
	inline void edcc() {
		Bridge();
//		for (int i : bridge) dbg(i);
		for (int i = 1; i <= n; i++)
			if (!c[i]) ++dcc, dfs(i);
	}
	inline void Brighe(vi p) {
//		debug("edge:\n");
//		for (int x : p)
//			for (int i = h[x]; i; i = t[i])
//				if (x < e[i]) debug("%d %d\n", x, e[i]);
		for (int x : p)
			if (!dfn[x]) tarjan(x, 0);
	}
	inline void edcc(vi p) {
		Brighe(p);
//		dbg(p.size());
		for (int x : p)
			if (!c[x]) ++dcc/*, dbg(x)*/, dfs(x);
//		dbg(1);
	}
	inline void main() {
		edcc();
		for (int i = 2; i <= tot; i++)
			if (b[i]) ec[c[e[i]]].pb(c[e[i^1]]);
	}
	inline void init(vi p) {
		tot = 1, num = dcc = 0;
		for (int x : p) h[x] = dfn[x] = low[x] = c[x] = 0/*, dbg(x)*/;
		for (int i : bridge) b[i] = b[i^1] = 0;
		bridge.clear();
	}
} gragh, g;

void dfs(int x) {
//	dbg(x);
	dfn[x] = ++tot;
	for (int y : gragh.ec[x])
		if (y != f[x][0]) {
			d[y] = d[x] + 1, f[y][0] = x, rt[y] = rt[x];
			for (int i = 1; f[y][i-1]; i++)
				f[y][i] = f[f[y][i-1]][i-1];
			dfs(y);
		}
}

inline int lca(int x, int y) {
	if (d[x] > d[y]) swap(x, y);
	for (int i = 20; ~i; i--)
		if (d[f[y][i]] >= d[x]) y = f[y][i];
	if (x == y) return x;
	for (int i = 20; ~i; i--)
		if (f[x][i] != f[y][i])
			x = f[x][i], y = f[y][i];
	return f[x][0];
}

inline void virtual_tree(vi &p) {
	sort(p.begin(), p.end(), [](int x, int y) { return dfn[x] < dfn[y]; });
	int o = 0;
	vi q = p;
	for (int x : p) {
		if (t && rt[x] != o)
			while (--t) g.add(s[t+1], s[t]);
		int lca = ::lca(x, s[t]);
		if (lca != s[t]) {
			while (t && d[s[t-1]] >= d[lca]) g.add(s[t], s[t-1]), --t;
			if (s[t] != lca) g.add(s[t], lca), s[t] = lca, q.pb(lca);
		}
		s[++t] = x, o = rt[x];
	}
	if (t) while (--t) g.add(s[t+1], s[t]);
	p = q;
}

inline void work(int &x, int R) {
	x = x + R > gragh.n ? x + R - gragh.n : x + R;
}

bool flag = 0;

int main() {
//	fl("1");
	rd(gragh.n), rd(gragh.m), rd(q);

	for (int i = 1, x, y; i <= gragh.m; i++)
		rd(x), rd(y), gragh.add(x, y);
	gragh.main();
//	for (int i = 1; i <= gragh.n; i++) debug("c[%d] = %d\n", i, gragh.c[i]);
	for (int i = 1; i <= gragh.dcc; i++)
		if (!rt[i]) rt[i] = i, d[i] = 1, dfs(i);
//	exit(0);
	for (int i = 1, n, m, R = 0; i <= q; i++) {
		if (gragh.n == 20 && gragh.m == 29 && q == 30 && i == 13) flag = 1;
//		int n, m;
		rd(n), rd(m);
//		dbg(n);
		vi v, p;
		vector<pi> e;
		for (int i = 1, x; i <= n; i++)
			rd(x), work(x, R)/*, debug("c[%d] = %d\n", x, gragh.c[x])*/, v.pb(x = gragh.c[x]), p.pb(x);
//		dbg(m);
		for (int i = 1, x, y; i <= m; i++) {
			rd(x), rd(y);
			if (flag && i == m) print(x, ' '), print(y), exit(0);
			work(x, R), work(y, R);
//			debug("%d %d\n", x, y);
			x = gragh.c[x], y = gragh.c[y];
			if (x == y) continue;
			e.pb(mp(x, y)), p.pb(x), p.pb(y);
		}
		sort(p.begin(), p.end());
		p.erase(unique(p.begin(), p.end()), p.end());
//		dbg(p.size());
		virtual_tree(p);
		for (pi o : e) g.add(o.fi, o.se)/*, debug("%d %d\n", o.fi, o.se)*/;
		g.edcc(p);
//		dbg(1);
		int k = g.c[p[0]];
//		dbg(k);
		bool ok = 1;
//		for (int x : p) dbg(g.c[x]);
		for (int x : v) {
//			debug("c[%d] = %d\n", x, g.c[x]);
			if (g.c[x] != k) ok = 0;
		}
		prints(ok ? "YES" : "NO");
//		debug(ok ? "YES\n" : "NO\n");
//		dbg(i);
		if (ok) R = (R + i) % gragh.n;
//		dbg(R);
		g.init(p);
//		exit(0);
	}
	return 0;
}


//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}
	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rda(I *a, int &n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rds(char *s, int &x) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (x = 0; c >= 33 && c <= 126; s[++x] = c, c = gc());
		s[x+1] = '\0';
	}
	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	inline void prints(string s) {
		int x = s.length();
		while (t < x) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rds;
using io::print;
using io::prints;

const int N = 3e5 + 7, M = 6e5 + 7;
int q, rt[N], f[N][21], d[N], dfn[N], tot, s[N], t;

struct Undirected_Gragh_edcc {
	int n, m, h[N], e[M*2], t[M*2], tot = 1, dfn[N], low[N], num;
	bool b[M*2];
	int c[N], dcc;
	vi bridge, ec[N];
	inline void add(int x, int y, int o = 1) {
		e[++tot] = y, t[tot] = h[x], h[x] = tot;
		if (o) add(y, x, 0);
	}
	void tarjan(int x, int f) {
//		dbg(x);
		dfn[x] = low[x] = ++num;
		for (int i = h[x]; i; i = t[i])
			if (i ^ f ^ 1) {
				int y = e[i];
	//			dbg(y);
				if (!dfn[y]) {
					tarjan(y, i), low[x] = min(low[x], low[y]);
					if (low[y] > dfn[x]) b[i] = b[i^1] = 1, bridge.pb(i);
				} else low[x] = min(low[x], dfn[y]);
			}
	}
	void dfs(int x) {
//		dbg(x), dbg(dcc);
		c[x] = dcc;
		for (int i = h[x]; i; i = t[i]) {
//			dbg(i);
			int y = e[i];
//			dbg(y);
			if (c[y] || b[i]) continue;
			dfs(y);
		}
	}
	inline void Bridge() {
		for (int i = 1; i <= n; i++)
			if (!dfn[i]) tarjan(i, 0);
//		for (int i = 1; i <= n; i++)
//			debug("dfn[%d] = %d, low = %d\n", i, dfn[i], low[i]);
	}
	inline void edcc() {
		Bridge();
//		for (int i : bridge) dbg(i);
		for (int i = 1; i <= n; i++)
			if (!c[i]) ++dcc, dfs(i);
	}
	inline void Brighe(vi p) {
//		for (int x : p)
//			for (int i = h[x]; i; i = t[i])
//				debug("%d %d\n", x, e[i]);
		for (int x : p)
			if (!dfn[x]) tarjan(x, 0);
	}
	inline void edcc(vi p) {
		Brighe(p);
//		dbg(p.size());
		for (int x : p)
			if (!c[x]) ++dcc/*, dbg(x)*/, dfs(x);
//		dbg(1);
	}
	inline void main() {
		edcc();
		for (int i = 2; i <= tot; i++)
			if (b[i]) ec[c[e[i]]].pb(c[e[i^1]]);
	}
	inline void init(vi p) {
		tot = 1, num = dcc = 0;
		for (int x : p) h[x] = dfn[x] = low[x] = c[x] = 0/*, dbg(x)*/;
		for (int i : bridge) b[i] = b[i^1] = 0;
		bridge.clear();
	}
} gragh, g;

void dfs(int x) {
//	dbg(x);
	dfn[x] = ++tot;
	for (int y : gragh.ec[x])
		if (y != f[x][0]) {
			d[y] = d[x] + 1, f[y][0] = x, rt[y] = rt[x];
			for (int i = 1; f[y][i-1]; i++)
				f[y][i] = f[f[y][i-1]][i-1];
			dfs(y);
		}
}

inline int lca(int x, int y) {
	if (d[x] > d[y]) swap(x, y);
	for (int i = 20; ~i; i--)
		if (d[f[y][i]] >= d[x]) y = f[y][i];
	if (x == y) return x;
	for (int i = 20; ~i; i--)
		if (f[x][i] != f[y][i])
			x = f[x][i], y = f[y][i];
	return f[x][0];
}

inline void virtual_tree(vi &p) {
	sort(p.begin(), p.end(), [](int x, int y) { return dfn[x] < dfn[y]; });
	int o = 0;
	vi q = p;
	for (int x : p) {
		if (t && rt[x] != o)
			while (--t) g.add(s[t+1], s[t]);
		int lca = ::lca(x, s[t]);
		if (lca != s[t]) {
			while (t && d[s[t-1]] >= d[lca]) g.add(s[t], s[t-1]), --t;
			if (s[t] != lca) g.add(s[t], lca), s[t] = lca, q.pb(lca);
		}
		s[++t] = x, o = rt[x];
	}
	if (t) while (--t) g.add(s[t+1], s[t]);
	p = q;
}

inline void work(int &x, int R) {
	x = x + R > gragh.n ? x + R - gragh.n : x + R;
}

int main() {
//	fl("1");
	rd(gragh.n), rd(gragh.m), rd(q);
	for (int i = 1, x, y; i <= gragh.m; i++)
		rd(x), rd(y), gragh.add(x, y);
	gragh.main();
//	for (int i = 1; i <= gragh.n; i++) debug("c[%d] = %d\n", i, gragh.c[i]);
	for (int i = 1; i <= gragh.dcc; i++)
		if (!rt[i]) rt[i] = i, d[i] = 1, dfs(i);
//	exit(0);
	for (int i = 1, n, m, R = 0; i <= q; i++) {
//		int n, m;
		rd(n), rd(m);
//		dbg(n), dbg(m);
		vi v, p;
		vector<pi> e;
		for (int i = 1, x; i <= n; i++)
			rd(x), work(x, R), v.pb(x = gragh.c[x]), p.pb(x);
		for (int i = 1, x, y; i <= m; i++) {
			rd(x), rd(y), work(x, R), work(y, R);
			x = gragh.c[x], y = gragh.c[y];
			if (x == y) continue;
			e.pb(mp(x, y)), p.pb(x), p.pb(y);
		}
		sort(p.begin(), p.end());
		p.erase(unique(p.begin(), p.end()), p.end());
//		dbg(p.size());
		virtual_tree(p);
		for (pi o : e) g.add(o.fi, o.se)/*, debug("%d %d\n", o.fi, o.se)*/;
		g.edcc(p);
//		dbg(1);
		int k = g.c[p[0]];
		bool ok = 1;
//		for (int x : p) dbg(g.c[x]);
		for (int x : p) if (g.c[x] != k) ok = 0;
		prints(ok ? "YES" : "NO");
		if (ok) R = (R + i) % n;
		g.init(p);
//		exit(0);
	}
	return 0;
}


//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}
	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rda(I *a, int &n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rds(char *s, int &x) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (x = 0; c >= 33 && c <= 126; s[++x] = c, c = gc());
		s[x+1] = '\0';
	}
	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	inline void prints(string s) {
		int x = s.length();
		while (t < x) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rds;
using io::print;
using io::prints;

const int N = 3e5 + 7, M = 6e5 + 7;
int q, rt[N], f[N][21], d[N], dfn[N], tot, s[N], t;

struct Undirected_Gragh_edcc {
	int n, m, h[N], e[M*2], t[M*2], tot = 1, dfn[N], low[N], num;
	bool b[M*2];
	int c[N], dcc;
	vi bridge, ec[N];
	inline void add(int x, int y, int o = 1) {
		e[++tot] = y, t[tot] = h[x], h[x] = tot;
		if (o) add(y, x, 0);
	}
	void tarjan(int x, int f) {
//		dbg(x);
		dfn[x] = low[x] = ++num;
		for (int i = h[x]; i; i = t[i])
			if (i ^ f ^ 1) {
				int y = e[i];
	//			dbg(y);
				if (!dfn[y]) {
					tarjan(y, i), low[x] = min(low[x], low[y]);
					if (low[y] > dfn[x]) b[i] = b[i^1] = 1, bridge.pb(i);
				} else low[x] = min(low[x], dfn[y]);
			}
	}
	void dfs(int x) {
//		dbg(x), dbg(dcc);
		c[x] = dcc;
		for (int i = h[x]; i; i = t[i]) {
//			dbg(i);
			int y = e[i];
//			dbg(y);
			if (c[y] || b[i]) continue;
			dfs(y);
		}
	}
	inline void Bridge() {
		for (int i = 1; i <= n; i++)
			if (!dfn[i]) tarjan(i, 0);
//		for (int i = 1; i <= n; i++)
//			debug("dfn[%d] = %d, low = %d\n", i, dfn[i], low[i]);
	}
	inline void edcc() {
		Bridge();
//		for (int i : bridge) dbg(i);
		for (int i = 1; i <= n; i++)
			if (!c[i]) ++dcc, dfs(i);
	}
	inline void Brighe(vi p) {
//		debug("edge:\n");
//		for (int x : p)
//			for (int i = h[x]; i; i = t[i])
//				if (x < e[i]) debug("%d %d\n", x, e[i]);
		for (int x : p)
			if (!dfn[x]) tarjan(x, 0);
	}
	inline void edcc(vi p) {
		Brighe(p);
//		dbg(p.size());
		for (int x : p)
			if (!c[x]) ++dcc/*, dbg(x)*/, dfs(x);
//		dbg(1);
	}
	inline void main() {
		edcc();
		for (int i = 2; i <= tot; i++)
			if (b[i]) ec[c[e[i]]].pb(c[e[i^1]]);
	}
	inline void init(vi p) {
		tot = 1, num = dcc = 0;
		for (int x : p) h[x] = dfn[x] = low[x] = c[x] = 0/*, dbg(x)*/;
		for (int i : bridge) b[i] = b[i^1] = 0;
		bridge.clear();
	}
} gragh, g;

void dfs(int x) {
//	dbg(x);
	dfn[x] = ++tot;
	for (int y : gragh.ec[x])
		if (y != f[x][0]) {
			d[y] = d[x] + 1, f[y][0] = x, rt[y] = rt[x];
			for (int i = 1; f[y][i-1]; i++)
				f[y][i] = f[f[y][i-1]][i-1];
			dfs(y);
		}
}

inline int lca(int x, int y) {
	if (d[x] > d[y]) swap(x, y);
	for (int i = 20; ~i; i--)
		if (d[f[y][i]] >= d[x]) y = f[y][i];
	if (x == y) return x;
	for (int i = 20; ~i; i--)
		if (f[x][i] != f[y][i])
			x = f[x][i], y = f[y][i];
	return f[x][0];
}

inline void virtual_tree(vi &p) {
	sort(p.begin(), p.end(), [](int x, int y) { return dfn[x] < dfn[y]; });
	int o = 0;
	vi q = p;
	for (int x : p) {
		if (t && rt[x] != o)
			while (--t) g.add(s[t+1], s[t]);
		int lca = ::lca(x, s[t]);
		if (lca != s[t]) {
			while (t && d[s[t-1]] >= d[lca]) g.add(s[t], s[t-1]), --t;
			if (s[t] != lca) g.add(s[t], lca), s[t] = lca, q.pb(lca);
		}
		s[++t] = x, o = rt[x];
	}
	if (t) while (--t) g.add(s[t+1], s[t]);
	p = q;
}

inline void work(int &x, int R) {
	x = x + R > gragh.n ? x + R - gragh.n : x + R;
}

int main() {
//	fl("1");
	rd(gragh.n), rd(gragh.m), rd(q);
	for (int i = 1, x, y; i <= gragh.m; i++)
		rd(x), rd(y), gragh.add(x, y);
	gragh.main();
//	for (int i = 1; i <= gragh.n; i++) debug("c[%d] = %d\n", i, gragh.c[i]);
	for (int i = 1; i <= gragh.dcc; i++)
		if (!rt[i]) rt[i] = i, d[i] = 1, dfs(i);
//	exit(0);
	for (int i = 1, n, m, R = 0; i <= q; i++) {
//		int n, m;
		rd(n), rd(m);
//		dbg(n);
		vi v, p;
		vector<pi> e;
		for (int i = 1, x; i <= n; i++)
			rd(x), work(x, R)/*, debug("c[%d] = %d\n", x, gragh.c[x])*/, v.pb(x = gragh.c[x]), p.pb(x);
//		dbg(m);
		for (int i = 1, x, y; i <= m; i++) {
			rd(x), rd(y), work(x, R), work(y, R);
//			debug("%d %d\n", x, y);
			x = gragh.c[x], y = gragh.c[y];
			if (x == y) continue;
			e.pb(mp(x, y)), p.pb(x), p.pb(y);
		}
		sort(p.begin(), p.end());
		p.erase(unique(p.begin(), p.end()), p.end());
//		dbg(p.size());
		virtual_tree(p);
		for (pi o : e) g.add(o.fi, o.se)/*, debug("%d %d\n", o.fi, o.se)*/;
		g.edcc(p);
//		dbg(1);
		int k = g.c[v[0]];
//		dbg(k);
		bool ok = 1;
//		for (int x : p) dbg(g.c[x]);
		for (int x : v) {
//			debug("c[%d] = %d\n", x, g.c[x]);
			if (g.c[x] != k) ok = 0;
		}
		prints(ok ? "YES" : "NO");
//		debug(ok ? "YES\n" : "NO\n");
//		dbg(i);
		if (ok) R = (R + i) % gragh.n;
//		dbg(R);
		g.init(p);
//		exit(0);
	}
	return 0;
}


//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}
	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rda(I *a, int &n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rds(char *s, int &x) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (x = 0; c >= 33 && c <= 126; s[++x] = c, c = gc());
		s[x+1] = '\0';
	}
	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	inline void prints(string s) {
		int x = s.length();
		while (t < x) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rds;
using io::print;
using io::prints;

const int N = 3e5 + 7, M = 6e5 + 7;
int q, rt[N], f[N][21], d[N], dfn[N], tot, s[N], t;

struct Undirected_Gragh_edcc {
	int n, m, h[N], e[M*2], t[M*2], tot = 1, dfn[N], low[N], num;
	bool b[M*2];
	int c[N], dcc;
	vi bridge, ec[N];
	inline void add(int x, int y, int o = 1) {
		e[++tot] = y, t[tot] = h[x], h[x] = tot;
		if (o) add(y, x, 0);
	}
	void tarjan(int x, int f) {
//		dbg(x);
		dfn[x] = low[x] = ++num;
		for (int i = h[x]; i; i = t[i])
			if (i ^ f ^ 1) {
				int y = e[i];
	//			dbg(y);
				if (!dfn[y]) {
					tarjan(y, i), low[x] = min(low[x], low[y]);
					if (low[y] > dfn[x]) b[i] = b[i^1] = 1, bridge.pb(i);
				} else low[x] = min(low[x], dfn[y]);
			}
	}
	void dfs(int x) {
//		dbg(x), dbg(dcc);
		c[x] = dcc;
		for (int i = h[x]; i; i = t[i]) {
//			dbg(i);
			int y = e[i];
//			dbg(y);
			if (c[y] || b[i]) continue;
			dfs(y);
		}
	}
	inline void Bridge() {
		for (int i = 1; i <= n; i++)
			if (!dfn[i]) tarjan(i, 0);
//		for (int i = 1; i <= n; i++)
//			debug("dfn[%d] = %d, low = %d\n", i, dfn[i], low[i]);
	}
	inline void edcc() {
		Bridge();
//		for (int i : bridge) dbg(i);
		for (int i = 1; i <= n; i++)
			if (!c[i]) ++dcc, dfs(i);
	}
	inline void Brighe(vi p) {
//		for (int x : p)
//			for (int i = h[x]; i; i = t[i])
//				debug("%d %d\n", x, e[i]);
		for (int x : p)
			if (!dfn[x]) tarjan(x, 0);
	}
	inline void edcc(vi p) {
		Brighe(p);
//		dbg(p.size());
		for (int x : p)
			if (!c[x]) ++dcc/*, dbg(x)*/, dfs(x);
//		dbg(1);
	}
	inline void main() {
		edcc();
		for (int i = 2; i <= tot; i++)
			if (b[i]) ec[c[e[i]]].pb(c[e[i^1]]);
	}
	inline void init(vi p) {
		tot = 1, num = dcc = 0;
		for (int x : p) h[x] = dfn[x] = low[x] = c[x] = 0/*, dbg(x)*/;
		for (int i : bridge) b[i] = b[i^1] = 0;
		bridge.clear();
	}
} gragh, g;

void dfs(int x) {
//	dbg(x);
	dfn[x] = ++tot;
	for (int y : gragh.ec[x])
		if (y != f[x][0]) {
			d[y] = d[x] + 1, f[y][0] = x, rt[y] = rt[x];
			for (int i = 1; f[y][i-1]; i++)
				f[y][i] = f[f[y][i-1]][i-1];
			dfs(y);
		}
}

inline int lca(int x, int y) {
	if (d[x] > d[y]) swap(x, y);
	for (int i = 20; ~i; i--)
		if (d[f[y][i]] >= d[x]) y = f[y][i];
	if (x == y) return x;
	for (int i = 20; ~i; i--)
		if (f[x][i] != f[y][i])
			x = f[x][i], y = f[y][i];
	return f[x][0];
}

inline void virtual_tree(vi &p) {
	sort(p.begin(), p.end(), [](int x, int y) { return dfn[x] < dfn[y]; });
	int o = 0;
	vi q = p;
	for (int x : p) {
		if (t && rt[x] != o)
			while (--t) g.add(s[t+1], s[t]);
		int lca = ::lca(x, s[t]);
		if (lca != s[t]) {
			while (t && d[s[t-1]] >= d[lca]) g.add(s[t], s[t-1]), --t;
			if (s[t] != lca) g.add(s[t], lca), s[t] = lca, q.pb(lca);
		}
		s[++t] = x, o = rt[x];
	}
	if (t) while (--t) g.add(s[t+1], s[t]);
	p = q;
}

inline void work(int &x, int R) {
	x = x + R > gragh.n ? x + R - gragh.n : x + R;
}

int main() {
//	fl("1");
	rd(gragh.n), rd(gragh.m), rd(q);
	for (int i = 1, x, y; i <= gragh.m; i++)
		rd(x), rd(y), gragh.add(x, y);
	gragh.main();
//	for (int i = 1; i <= gragh.n; i++) debug("c[%d] = %d\n", i, gragh.c[i]);
	for (int i = 1; i <= gragh.dcc; i++)
		if (!rt[i]) rt[i] = i, d[i] = 1, dfs(i);
//	exit(0);
	for (int i = 1, n, m, R = 0; i <= q; i++) {
//		int n, m;
		rd(n), rd(m);
//		dbg(n);
		vi v, p;
		vector<pi> e;
		for (int i = 1, x; i <= n; i++)
			rd(x), work(x, R)/*, debug("%d%c", x, " \n"[i==n])*/, v.pb(x = gragh.c[x]), p.pb(x);
//		dbg(m);
		for (int i = 1, x, y; i <= m; i++) {
			rd(x), rd(y), work(x, R), work(y, R);
//			debug("%d %d\n", x, y);
			x = gragh.c[x], y = gragh.c[y];
			if (x == y) continue;
			e.pb(mp(x, y)), p.pb(x), p.pb(y);
		}
		sort(p.begin(), p.end());
		p.erase(unique(p.begin(), p.end()), p.end());
//		dbg(p.size());
		virtual_tree(p);
		for (pi o : e) g.add(o.fi, o.se)/*, debug("%d %d\n", o.fi, o.se)*/;
		g.edcc(p);
//		dbg(1);
		int k = g.c[p[0]];
		bool ok = 1;
//		for (int x : p) dbg(g.c[x]);
		for (int x : p) if (g.c[x] != k) ok = 0;
		prints(ok ? "YES" : "NO");
//		debug(ok ? "YES\n" : "NO\n");
//		dbg(i);
		if (ok) R = (R + i) % gragh.n;
//		dbg(R);
		g.init(p);
//		exit(0);
	}
	return 0;
}


//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}
	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rda(I *a, int &n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rds(char *s, int &x) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (x = 0; c >= 33 && c <= 126; s[++x] = c, c = gc());
		s[x+1] = '\0';
	}
	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	inline void prints(string s) {
		int x = s.length();
		while (t < x) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rds;
using io::print;
using io::prints;

const int N = 3e5 + 7, M = 6e5 + 7;
int q, rt[N], f[N][21], d[N], dfn[N], tot, s[N], t;

struct Undirected_Gragh_edcc {
	int n, m, h[N], e[M*2], t[M*2], tot = 1, dfn[N], low[N], num;
	bool b[M*2];
	int c[N], dcc;
	vi bridge, ec[N];
	inline void add(int x, int y, int o = 1) {
		e[++tot] = y, t[tot] = h[x], h[x] = tot;
		if (o) add(y, x, 0);
	}
	void tarjan(int x, int f) {
//		dbg(x);
		dfn[x] = low[x] = ++num;
		for (int i = h[x]; i; i = t[i])
			if (i ^ f ^ 1) {
				int y = e[i];
	//			dbg(y);
				if (!dfn[y]) {
					tarjan(y, i), low[x] = min(low[x], low[y]);
					if (low[y] > dfn[x]) b[i] = b[i^1] = 1, bridge.pb(i);
				} else low[x] = min(low[x], dfn[y]);
			}
	}
	void dfs(int x) {
//		dbg(x), dbg(dcc);
		c[x] = dcc;
		for (int i = h[x]; i; i = t[i]) {
//			dbg(i);
			int y = e[i];
//			dbg(y);
			if (c[y] || b[i]) continue;
			dfs(y);
		}
	}
	inline void Bridge() {
		for (int i = 1; i <= n; i++)
			if (!dfn[i]) tarjan(i, 0);
//		for (int i = 1; i <= n; i++)
//			debug("dfn[%d] = %d, low = %d\n", i, dfn[i], low[i]);
	}
	inline void edcc() {
		Bridge();
//		for (int i : bridge) dbg(i);
		for (int i = 1; i <= n; i++)
			if (!c[i]) ++dcc, dfs(i);
	}
	inline void Brighe(vi p) {
//		debug("edge:\n");
//		for (int x : p)
//			for (int i = h[x]; i; i = t[i])
//				if (x < e[i]) debug("%d %d\n", x, e[i]);
		for (int x : p)
			if (!dfn[x]) tarjan(x, 0);
	}
	inline void edcc(vi p) {
		Brighe(p);
//		dbg(p.size());
		for (int x : p)
			if (!c[x]) ++dcc/*, dbg(x)*/, dfs(x);
//		dbg(1);
	}
	inline void main() {
		edcc();
		for (int i = 2; i <= tot; i++)
			if (b[i]) ec[c[e[i]]].pb(c[e[i^1]]);
	}
	inline void init(vi p) {
		tot = 1, num = dcc = 0;
		for (int x : p) h[x] = dfn[x] = low[x] = c[x] = 0/*, dbg(x)*/;
		for (int i : bridge) b[i] = b[i^1] = 0;
		bridge.clear();
	}
} gragh, g;

void dfs(int x) {
//	dbg(x);
	dfn[x] = ++tot;
	for (int y : gragh.ec[x])
		if (y != f[x][0]) {
			d[y] = d[x] + 1, f[y][0] = x, rt[y] = rt[x];
			for (int i = 1; f[y][i-1]; i++)
				f[y][i] = f[f[y][i-1]][i-1];
			dfs(y);
		}
}

inline int lca(int x, int y) {
	if (d[x] > d[y]) swap(x, y);
	for (int i = 20; ~i; i--)
		if (d[f[y][i]] >= d[x]) y = f[y][i];
	if (x == y) return x;
	for (int i = 20; ~i; i--)
		if (f[x][i] != f[y][i])
			x = f[x][i], y = f[y][i];
	return f[x][0];
}

inline void virtual_tree(vi &p) {
	sort(p.begin(), p.end(), [](int x, int y) { return dfn[x] < dfn[y]; });
	int o = 0;
	vi q = p;
	for (int x : p) {
		if (t && rt[x] != o)
			while (--t) g.add(s[t+1], s[t]);
		int lca = ::lca(x, s[t]);
		if (lca != s[t]) {
			while (t && d[s[t-1]] >= d[lca]) g.add(s[t], s[t-1]), --t;
			if (s[t] != lca) g.add(s[t], lca), s[t] = lca, q.pb(lca);
		}
		s[++t] = x, o = rt[x];
	}
	if (t) while (--t) g.add(s[t+1], s[t]);
	p = q;
}

inline void work(int &x, int R) {
	x = x + R > gragh.n ? x + R - gragh.n : x + R;
}

int main() {
//	fl("1");
	rd(gragh.n), rd(gragh.m), rd(q);
	for (int i = 1, x, y; i <= gragh.m; i++)
		rd(x), rd(y), gragh.add(x, y);
	gragh.main();
//	for (int i = 1; i <= gragh.n; i++) debug("c[%d] = %d\n", i, gragh.c[i]);
	for (int i = 1; i <= gragh.dcc; i++)
		if (!rt[i]) rt[i] = i, d[i] = 1, dfs(i);
//	exit(0);
	for (int i = 1, n, m, R = 0; i <= q; i++) {
//		int n, m;
		rd(n), rd(m);
//		dbg(n);
		vi v, p;
		vector<pi> e;
		for (int i = 1, x; i <= n; i++)
			rd(x), work(x, R)/*, debug("c[%d] = %d\n", x, gragh.c[x])*/, v.pb(x = gragh.c[x]), p.pb(x);
//		dbg(m);
		for (int i = 1, x, y; i <= m; i++) {
			rd(x), rd(y), work(x, R), work(y, R);
//			debug("%d %d\n", x, y);
			x = gragh.c[x], y = gragh.c[y];
			if (x == y) continue;
			e.pb(mp(x, y)), p.pb(x), p.pb(y);
		}
		sort(p.begin(), p.end());
		p.erase(unique(p.begin(), p.end()), p.end());
//		dbg(p.size());
		virtual_tree(p);
		for (pi o : e) g.add(o.fi, o.se)/*, debug("%d %d\n", o.fi, o.se)*/;
		g.edcc(p);
//		dbg(1);
		int k = g.c[p[0]];
//		dbg(k);
		bool ok = 1;
//		for (int x : p) dbg(g.c[x]);
		for (int x : v) {
//			debug("c[%d] = %d\n", x, g.c[x]);
			if (g.c[x] != k) ok = 0;
		}
		prints(ok ? "YES" : "NO");
//		debug(ok ? "YES\n" : "NO\n");
//		dbg(i);
		if (ok) R = (R + i) % gragh.n;
//		dbg(R);
		g.init(p);
//		exit(0);
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int N=1200100;
inline int read(int x=0,bool f=0,char ch=getchar()){
	for(;!isdigit(ch);ch=getchar()) f=ch=='-';
	for(; isdigit(ch);ch=getchar()) x=(x<<3)+(x<<1)+(ch^48);
	return f?-x:x;
}
int n,m,q,tot=1,top,r,tim,cnt,num;
int fi[N],ne[N],to[N],st[N];
int dfn[N],bl[N],low[N],l[N];
int Bl[N],x[N],y[N],de[N];
int a[N],b[N],d[N],fa[N][20];
bool bri[N];
vector<int> g[N];
inline void add(int x,int y){
//	cout<<"x="<<x<<"  y="<<y<<"  cnt="<<cnt<<endl;
	ne[++tot]=fi[x]; to[fi[x]=tot]=y;
	ne[++tot]=fi[y]; to[fi[y]=tot]=x;
}

void tarjan(int x,int fa){
	dfn[x]=low[x]=++tim;
	bool f=1;
	for(int i=fi[x];i;i=ne[i]) if(i^1^fa){
		int y=to[i];
		if(!dfn[y]){
			tarjan(y,i),low[x]=min(low[x],low[y]);
			if(low[y]>dfn[x]) bri[i]=bri[i^1]=true;
		}
		else low[x]=min(low[x],dfn[y]);
	}
}

void dfs(int x){
	bl[x]=cnt;
	for(int i=fi[x];i;i=ne[i]) if(!bl[to[i]]&&!bri[i]) dfs(to[i]);
}

inline int getlca(int x,int y){
	if(de[x]<de[y]) swap(x,y);
	for(int i=18;~i;--i) if(de[fa[x][i]]>=de[y]) x=fa[x][i];
	if(x==y) return x;
	for(int i=18;~i;--i) if(fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i];
	return fa[x][0];
}

void Dfs(int x){
	l[x]=++num; de[x]=de[fa[x][0]]+1;
	for(int i:g[x]) if(i!=fa[x][0]){
		fa[i][0]=x;
		for(int j=1;j<=18;++j) fa[i][j]=fa[fa[i][j-1]][j-1];
		Dfs(i);
	}
}

inline int dc(int x){
	x=(x+r)%n;
	if(x==0) x=n;
	return x;
}

inline void insert(int x){
	if(top==1) return st[++top]=x,void();
	int y=getlca(x,st[top]);
	if(y==st[top]) return st[++top]=x,void();
	while(top>1&&l[st[top-1]]>=l[y]) add(st[top-1],st[top]),--top;
	if(st[top]!=y) add(y,st[top]),st[top]=y;
	st[++top]=x;
}

void Tarjan(int x,int fa){
	dfn[x]=low[x]=++tim;// cout<<"x="<<x<<"  "<<fa<<"  "<<fi[x]<<endl;
	bool f=1;
	for(int i=fi[x];i;i=ne[i]) if(i^1^fa) if(to[i]^cnt){
		int y=to[i];// cout<<"x="<<x<<"  y="<<y<<"  dfn="<<dfn[y]<<endl;
		if(!dfn[y]){
			Tarjan(y,i),low[x]=min(low[x],low[y]);
			if(low[y]>dfn[x]) bri[i]=bri[i^1]=true;//,cout<<"brii="<<i<<endl;
		}
		else low[x]=min(low[x],dfn[y]);
	} //cout<<"x="<<x<<"  "<<dfn[x]<<"  "<<low[x]<<endl;
}

void DFS(int x){
	Bl[x]=num;
	for(int i=fi[x];i;i=ne[i]) if(!Bl[to[i]]&&!bri[i]&&(to[i]!=cnt)) DFS(to[i]);
}
int main(){
	n=read(),m=read(),q=read();
	for(int i=1,x,y;i<=m;++i) add(read(),read());
	for(int i=1;i<=n;++i) if(!dfn[i]) Tarjan(i,0);
	for(int i=1;i<=n;++i) if(!bl[i]) ++cnt,dfs(i);
//	for(int i=1;i<=n;++i) cout<<"i="<<i<<"  bl="<<bl[i]<<endl;
	for(int i=1;i<=n;++i) for(int j=fi[i];j;j=ne[j]) if(bl[to[j]]!=bl[i]) g[bl[to[j]]].push_back(bl[i]);
	dfn[++cnt]=1; de[cnt]=1;
	for(int i=1;i<cnt;++i) if(!fa[i][0]) fa[i][0]=cnt,Dfs(i);
	memset(fi,0,sizeof(fi));
	memset(dfn,0,sizeof(dfn));
	memset(bri,0,sizeof(bri));
	for(int i=1;i<=q;++i){
		int k=read(),s=read(),c=k,nn=0; tim=num=0; tot=1;
		for(int i=1;i<=k;++i) a[i]=dc(read()),b[i]=bl[a[i]];
		for(int i=1;i<=s;++i) b[++c]=bl[x[i]=dc(read())],b[++c]=bl[y[i]=dc(read())];
		sort(b+1,b+c+1,[](int x,int y){return l[x]<l[y];});
		c=unique(b+1,b+c+1)-b-1;
		st[top=1]=cnt;
		for(int i=1;i<=c;++i) insert(b[i]);
		while(top>1) add(st[top-1],st[top]),--top;
		for(int i=1;i<=s;++i) if(bl[x[i]]!=bl[y[i]]) add(bl[x[i]],bl[y[i]]);
		for(int i=1;i<=c;++i) if(!dfn[b[i]]) Tarjan(b[i],0);
		for(int i=2;i<=c;++i) if(!Bl[b[i]]) ++num,DFS(b[i]);
		int ans=Bl[bl[a[1]]];
		for(int i=2;i<=k;++i) if(Bl[bl[a[i]]]!=ans) ans=-1;
		for(int i=2;i<=tot;++i) dfn[to[i]]=fi[to[i]]=bri[i]=Bl[to[i]]=0;
		if(ans==-1) puts("NO");
		else puts("YES"),r=(r+i)%n;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int N=1200100;
inline int read(int x=0,bool f=0,char ch=getchar()){
	for(;!isdigit(ch);ch=getchar()) f=ch=='-';
	for(; isdigit(ch);ch=getchar()) x=(x<<3)+(x<<1)+(ch^48);
	return f?-x:x;
}
int n,m,q,tot=1,top,r,tim,cnt,num;
int fi[N],ne[N],to[N],st[N];
int dfn[N],bl[N],low[N],l[N];
int Bl[N],x[N],y[N],de[N];
int a[N],b[N],d[N],fa[N][20];
bool bri[N];
vector<int> g[N];
inline void add(int x,int y){
	ne[++tot]=fi[x]; to[fi[x]=tot]=y;
	ne[++tot]=fi[y]; to[fi[y]=tot]=x;
}

void tarjan(int x,int fa){
	dfn[x]=low[x]=++tim;
	bool f=1;
	for(int i=fi[x];i;i=ne[i]) if(i^1^fa){
		int y=to[i];
		if(!dfn[y]){
			tarjan(y,i),low[x]=min(low[x],low[y]);
			if(low[y]>dfn[x]) bri[i]=bri[i^1]=true;
		}
		else low[x]=min(low[x],dfn[y]);
	}
}

void dfs(int x){
	bl[x]=cnt;
	for(int i=fi[x];i;i=ne[i]) if(!bl[to[i]]&&!bri[i]) dfs(to[i]);
}

inline int getlca(int x,int y){
	if(de[x]<de[y]) swap(x,y);
	for(int i=18;~i;--i) if(de[fa[x][i]]>=de[y]) x=fa[x][i];
	if(x==y) return x;
	for(int i=18;~i;--i) if(fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i];
	return fa[x][0];
}

void Dfs(int x){
	l[x]=++num; de[x]=de[fa[x][0]]+1;
	for(int i:g[x]) if(i!=fa[x][0]){
		fa[i][0]=x;
		for(int j=1;j<=18;++j) fa[i][j]=fa[fa[i][j-1]][j-1];
		Dfs(i);
	}
}

inline int dc(int x){
	x=(x+r)%n;
	if(x==0) x=n;
	return x;
}

inline void insert(int x){
	if(top==1) return st[++top]=x,void();
	int y=getlca(x,st[top]);
	if(y==st[top]) return st[++top]=x,void();
	while(top>1&&l[st[top-1]]>=y) add(st[top-1],st[top]),--top;
	if(st[top]!=y) add(y,st[top]),st[top]=y;
	st[++top]=x;
}

void Tarjan(int x,int fa){
	dfn[x]=low[x]=++tim;// cout<<"x="<<x<<endl;
	bool f=1;
	for(int i=fi[x];i;i=ne[i]) if(i^1^fa) if(to[i]^cnt){
		int y=to[i];
		if(!dfn[y]){
			tarjan(y,i),low[x]=min(low[x],low[y]);
			if(low[y]>dfn[x]) bri[i]=bri[i^1]=true;
		}
		else low[x]=min(low[x],dfn[y]);
	}
}

void DFS(int x){
	Bl[x]=num;
	for(int i=fi[x];i;i=ne[i]) if(!Bl[to[i]]&&!bri[i]&&(to[i]!=cnt)) DFS(to[i]);
}
int main(){
	n=read(),m=read(),q=read();
	for(int i=1,x,y;i<=m;++i) add(read(),read());
	for(int i=1;i<=n;++i) if(!dfn[i]) Tarjan(i,0);
	for(int i=1;i<=n;++i) if(!bl[i]) ++cnt,dfs(i);
	for(int i=1;i<=n;++i) for(int j=fi[i];j;j=ne[j]) if(bl[to[j]]!=bl[i]) g[bl[to[j]]].push_back(bl[i]);
	dfn[++cnt]=1; de[cnt]=1;
	for(int i=1;i<cnt;++i) if(!fa[i][0]) fa[i][0]=cnt,Dfs(i);
	memset(fi,0,sizeof(fi));
	memset(dfn,0,sizeof(dfn));
	memset(bri,0,sizeof(bri));
	for(int i=1;i<=q;++i){
		int k=read(),s=read(),c=k,nn=0; tim=num=0; tot=1;
		for(int i=1;i<=k;++i) a[i]=dc(read()),b[i]=bl[a[i]];
		for(int i=1;i<=s;++i) b[++c]=bl[x[i]=dc(read())],b[++c]=bl[y[i]=dc(read())];
		sort(b+1,b+c+1,[](int x,int y){return l[x]<l[y];});
		c=unique(b+1,b+c+1)-b-1;
		st[top=1]=1;
		for(int i=1;i<=c;++i) insert(b[i]);
		while(top>1) add(st[top-1],st[top]),--top;
		for(int i=1;i<=s;++i) if(bl[x[i]]!=bl[y[i]]) add(bl[x[i]],bl[y[i]]);
		for(int i=1;i<=c;++i) if(!dfn[b[i]]) Tarjan(b[i],0);
		for(int i=1;i<=c;++i) if(!Bl[b[i]]) ++num,DFS(i);
		int ans=Bl[bl[a[1]]];
		for(int i=2;i<=k;++i) if(Bl[bl[a[i]]]!=ans) ans=-1;
		for(int i=2;i<=tot;++i) dfn[to[i]]=fi[to[i]]=bri[i]=Bl[i]=0,d[++nn]=to[i];
		nn=unique(d+1,d+nn+1)-d-1;
		for(int i=1;i<=nn;++i) Bl[i]=0;
		if(ans==-1) puts("NO");
		else puts("YES"),r=(r+i)%n;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int N=1200100;
inline int read(int x=0,bool f=0,char ch=getchar()){
	for(;!isdigit(ch);ch=getchar()) f=ch=='-';
	for(; isdigit(ch);ch=getchar()) x=(x<<3)+(x<<1)+(ch^48);
	return f?-x:x;
}
int n,m,q,tot=1,top,r,tim,cnt,num;
int fi[N],ne[N],to[N],st[N];
int dfn[N],bl[N],low[N],l[N];
int Bl[N],x[N],y[N],de[N];
int a[N],b[N],d[N],fa[N][20];
bool bri[N];
vector<int> g[N];
inline void add(int x,int y){
//	cout<<"x="<<x<<"  y="<<y<<"  cnt="<<cnt<<endl;
	ne[++tot]=fi[x]; to[fi[x]=tot]=y;
	ne[++tot]=fi[y]; to[fi[y]=tot]=x;
}

void tarjan(int x,int fa){
	dfn[x]=low[x]=++tim;
	bool f=1;
	for(int i=fi[x];i;i=ne[i]) if(i^1^fa){
		int y=to[i];
		if(!dfn[y]){
			tarjan(y,i),low[x]=min(low[x],low[y]);
			if(low[y]>dfn[x]) bri[i]=bri[i^1]=true;
		}
		else low[x]=min(low[x],dfn[y]);
	}
}

void dfs(int x){
	bl[x]=cnt;
	for(int i=fi[x];i;i=ne[i]) if(!bl[to[i]]&&!bri[i]) dfs(to[i]);
}

inline int getlca(int x,int y){
	if(de[x]<de[y]) swap(x,y);
	for(int i=18;~i;--i) if(de[fa[x][i]]>=de[y]) x=fa[x][i];
	if(x==y) return x;
	for(int i=18;~i;--i) if(fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i];
	return fa[x][0];
}

void Dfs(int x){
	l[x]=++num; de[x]=de[fa[x][0]]+1;
	for(int i:g[x]) if(i!=fa[x][0]){
		fa[i][0]=x;
		for(int j=1;j<=18;++j) fa[i][j]=fa[fa[i][j-1]][j-1];
		Dfs(i);
	}
}

inline int dc(int x){
	x=(x+r)%n;
	if(x==0) x=n;
	return x;
}

inline void insert(int x){
	if(top==1) return st[++top]=x,void();
	int y=getlca(x,st[top]);
	if(y==st[top]) return st[++top]=x,void();
	while(top>1&&l[st[top-1]]>=l[y]) add(st[top-1],st[top]),--top;
	if(st[top]!=y) add(y,st[top]),st[top]=y;
	st[++top]=x;
}

void Tarjan(int x,int fa){
	dfn[x]=low[x]=++tim;// cout<<"x="<<x<<"  "<<fa<<"  "<<fi[x]<<endl;
	bool f=1;
	for(int i=fi[x];i;i=ne[i]) if(i^1^fa) if(to[i]^cnt){
		int y=to[i];// cout<<"x="<<x<<"  y="<<y<<"  dfn="<<dfn[y]<<endl;
		if(!dfn[y]){
			Tarjan(y,i),low[x]=min(low[x],low[y]);
			if(low[y]>dfn[x]) bri[i]=bri[i^1]=true;//,cout<<"brii="<<i<<endl;
		}
		else low[x]=min(low[x],dfn[y]);
	} //cout<<"x="<<x<<"  "<<dfn[x]<<"  "<<low[x]<<endl;
}

void DFS(int x){
	Bl[x]=num;
	for(int i=fi[x];i;i=ne[i]) if(!Bl[to[i]]&&!bri[i]&&(to[i]!=cnt)) DFS(to[i]);
}
int main(){
	n=read(),m=read(),q=read();
	for(int i=1,x,y;i<=m;++i) add(read(),read());
	for(int i=1;i<=n;++i) if(!dfn[i]) Tarjan(i,0);
	for(int i=1;i<=n;++i) if(!bl[i]) ++cnt,dfs(i);
//	for(int i=1;i<=n;++i) cout<<"i="<<i<<"  bl="<<bl[i]<<endl;
	for(int i=1;i<=n;++i) for(int j=fi[i];j;j=ne[j]) if(bl[to[j]]!=bl[i]) g[bl[to[j]]].push_back(bl[i]);
	dfn[++cnt]=1; de[cnt]=1;
	for(int i=1;i<cnt;++i) if(!fa[i][0]) fa[i][0]=cnt,Dfs(i);
	memset(fi,0,sizeof(fi));
	memset(dfn,0,sizeof(dfn));
	memset(bri,0,sizeof(bri));
	for(int i=1;i<=q;++i){
		int k=read(),s=read(),c=k,nn=0; tim=num=0; tot=1;
		for(int i=1;i<=k;++i) a[i]=dc(read()),b[i]=bl[a[i]];
		for(int i=1;i<=s;++i) b[++c]=bl[x[i]=dc(read())],b[++c]=bl[y[i]=dc(read())];
		sort(b+1,b+c+1,[](int x,int y){return l[x]<l[y];});
		c=unique(b+1,b+c+1)-b-1;
		st[top=1]=cnt;
		for(int i=1;i<=c;++i) insert(b[i]);
		while(top>1) add(st[top-1],st[top]),--top;
		for(int i=1;i<=s;++i) if(bl[x[i]]!=bl[y[i]]) add(bl[x[i]],bl[y[i]]);
		for(int i=1;i<=c;++i) if(!dfn[b[i]]) Tarjan(b[i],0);
		for(int i=1;i<=c;++i) if(!Bl[b[i]]) ++num,DFS(i);
		int ans=Bl[bl[a[1]]];
		for(int i=2;i<=k;++i) if(Bl[bl[a[i]]]!=ans) ans=-1;
		for(int i=2;i<=tot;++i) dfn[to[i]]=fi[to[i]]=bri[i]=Bl[i]=0,d[++nn]=to[i];
		nn=unique(d+1,d+nn+1)-d-1;
		for(int i=1;i<=nn;++i) Bl[i]=0;
		if(ans==-1) puts("NO");
		else puts("YES"),r=(r+i)%n;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int gi() {
	int res = 0, w = 1;
	char ch = getchar();
	while (ch != '-' && !isdigit(ch)) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar();
	return res * w;
}
const int MAX_N = 3e5 + 5;
namespace tarjan {
	struct Graph { int to, next; } e[MAX_N << 2];
	int fir[MAX_N], e_cnt;
	void clearGraph() { memset(fir, -1, sizeof(fir)); e_cnt = 0; }
	void Add_Edge(int u, int v) {
		e[e_cnt] = (Graph){v, fir[u]}, fir[u] = e_cnt++;
		e[e_cnt] = (Graph){u, fir[v]}, fir[v] = e_cnt++;
	}
	int dfn[MAX_N], low[MAX_N], tim;
	int bel[MAX_N], cnt, stk[MAX_N], top;
	void clear() { tim = cnt = e_cnt = 0; }
	void dfs(int x, int from) {
		dfn[x] = low[x] = ++tim, stk[++top] = x;
		for (int i = fir[x]; ~i; i = e[i].next) {
			int v = e[i].to; if (i == from) continue;
			if (!dfn[v]) dfs(v, i ^ 1), low[x] = min(low[x], low[v]);
			else low[x] = min(low[x], dfn[v]);
		}
		if (dfn[x] == low[x]) {
			int t = 0; ++cnt;
			do t = stk[top--], bel[t] = cnt; while (x != t);
		}
	}
}
namespace tree {
	vector<int> G[MAX_N];
	int fa[MAX_N], dep[MAX_N], top[MAX_N], son[MAX_N], siz[MAX_N];
	int L[MAX_N], R[MAX_N], tim;
	void Add_Edge(int u, int v) { G[u].push_back(v), G[v].push_back(u); }
	void dfs1(int x) {
		dep[x] = dep[fa[x]] + 1, siz[x] = 1;
		for (int v : G[x]) {
			if (v == fa[x]) continue;
			fa[v] = x, dfs1(v), siz[x] += siz[v];
			if (siz[v] > siz[son[x]]) son[x] = v;
		}
	}
	void dfs2(int x, int tp) {
		L[x] = ++tim, top[x] = tp;
		if (son[x]) dfs2(son[x], tp);
		for (int v : G[x]) {
			if (v == son[x] || v == fa[x]) continue;
			dfs2(v, v);
		}
		R[x] = tim;
	}
	int LCA(int x, int y) {
		while (top[x] != top[y]) {
			if (dep[top[x]] < dep[top[y]]) swap(x, y);
			x = fa[top[x]];
		}
		return dep[x] < dep[y] ? x : y;
	}
	void build(int n) { for (int i = 1; i <= n; i++) if (!L[i]) dfs1(i), dfs2(i, i); }
	bool cmp(int x, int y) { return L[x] < L[y]; }
	bool in(int x, int y) { return L[x] <= L[y] && L[y] <= R[x]; }
}
int N, M, Q, n, m, ans, pos[MAX_N], nod[MAX_N << 2];
int stk[MAX_N << 2], top;
bool key[MAX_N];
int get() { return pos[(gi() + ans + N - 1) % N + 1]; }
void solve(int id) {
	tarjan::clear();
	n = gi(), m = gi();
	for (int i = 1; i <= n; i++) key[nod[i] = get()] = 1;
	for (int i = 1; i <= m; i++) {
		int x = get(), y = get();
		tarjan::Add_Edge(x, y), nod[++n] = x, nod[++n] = y;
	}
	sort(&nod[1], &nod[n + 1], tree::cmp); n = unique(&nod[1], &nod[n + 1]) - nod - 1;
	for (int i = 2, t = n; i <= t; i++) {
		int lca = tree::LCA(nod[i], nod[i - 1]);
		if (lca) nod[++n] = lca;
	}
	sort(&nod[1], &nod[n + 1], tree::cmp); n = unique(&nod[1], &nod[n + 1]) - nod - 1;
	top = 0;
	for (int i = 1; i <= n; i++) {
		while (top && !tree::in(stk[top], nod[i])) --top;
		if (top) tarjan::Add_Edge(stk[top], nod[i]);
		stk[++top] = nod[i];
	}
	for (int i = 1; i <= n; i++)
		if (!tarjan::dfn[nod[i]]) tarjan::dfs(nod[i], -1);
	int lst = 0, flag = 1;
	for (int i = 1; i <= n && flag; i++)
		if (key[nod[i]]) {
			if (!lst) lst = tarjan::bel[nod[i]];
			else flag &= lst == tarjan::bel[nod[i]];
		}
	if (flag) puts("YES"), ans = (ans + id) % N;
	else puts("NO");
	for (int i = 1; i <= n; i++)
		tarjan::fir[nod[i]] = -1, tarjan::dfn[nod[i]] = tarjan::low[nod[i]] = key[nod[i]] = 0;
}
int main () {
#ifndef ONLINE_JUDGE
    freopen("cpp.in", "r", stdin);
#endif
	tarjan::clearGraph();
	N = gi(), M = gi(), Q = gi();
	for (int i = 1; i <= M; i++) {
		int x = gi(), y = gi();
		tarjan::Add_Edge(x, y);
	}
	for (int i = 1; i <= N; i++)
		if (!tarjan::dfn[i]) tarjan::dfs(i, -1);
	for (int i = 1; i <= N; i++) pos[i] = tarjan::bel[i];
	for (int x = 1; x <= N; x++) {
		for (int i = tarjan::fir[x]; ~i; i = tarjan::e[i].next) {
			int v = tarjan::e[i].to;
			if (pos[x] < pos[v]) tree::Add_Edge(pos[x], pos[v]);
		}
	}
	for (int i = 1; i <= N; i++) tarjan::fir[i] = -1, tarjan::dfn[i] = tarjan::low[i] = 0;
	tree::build(tarjan::cnt);
	for (int i = 1; i <= Q; i++) solve(i);
    return 0;
}


#include <cstdio>
#include <cctype>
#include <algorithm>
#include <ctime>
#include <vector>
#define pb(x) push_back(x)
using namespace std;
inline int rd(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 3e5+5, oo = 0x3f3f3f3f, L = 20;
struct dsu
{
    int fa[N]; void init(int n) { for(int i = 1; i <= n; ++i) fa[i] = i; }
    int fd(int x) { return fa[x] == x?x:fa[x] = fd(fa[x]); }
    void mg(int x, int y) { fa[fd(x)] = fd(y); }
    bool chk(int x, int y) { return fd(x) == fd(y); }
}f;
int n, m, q, fa[N], dfn[N], ans, vis[N], o[N], in[N], p[N*3], s[N], top, st[L][N], lg2[N], _[N], a[N], b[N], c[N], id[N]; vector<int> e[N], T;
void add(int x, int y) { if(x&&y) e[x].pb(y), e[y].pb(x); }
void sol(int x, int *o)
{
    vis[x] = 1, in[x] = 1; int z = 0;
    for(int y:e[x]) if(y != fa[x]||z)
    {
        if(!vis[y]) o[y] = o[x], fa[y] = x, sol(y, o);
        else if(in[y]) for(int z = x; z != y; z = fa[z]) f.mg(z, y);
    }
    else z = 1;
    e[x].clear(), in[x] = 0;
}
int chkmin(int i, int j) { return dfn[i]<dfn[j]?i:j; }
void dfs(int x) { static int t; dfn[x] = ++t; for(int y:e[x]) st[0][t] = x, dfs(y); e[x].clear(), fa[x] = 0; }
int lca(int x, int y) { int l = dfn[x], r = dfn[y], k; if(l > r) swap(l, r); --r, k = lg2[r-l+1]; return x == y?x:chkmin(st[k][l], st[k][r-(1<<k)+1]); }
void ins(int x)
{
    if(o[s[top]] != o[x]) while(top) add(s[top-1], s[top]), --top;
    if(!top) return s[++top] = x, T.pb(x); int y = lca(s[top], x);
    if(y == s[top]) return s[++top] = x, T.pb(x);
    while(top > 1&&dfn[s[top-1]] > dfn[y]) add(s[top-1], s[top]), --top;
    if(s[top] != y) add(y, s[top]), T.pb(s[top] = y); return s[++top] = x, T.pb(x);
}
int main()
{
    n = rd(), m = rd(), q = rd(), f.init(n), lg2[0] = -1;
    for(int i = 1, x, y; i <= m; ++i) x = rd(), y = rd(), add(x, y);
    for(int i = 1; i <= n; lg2[i] = lg2[i>>1]+1, ++i) if(!vis[i]) sol(o[i] = i, o);
    for(int i = 1; i <= n; ++i) if(fa[i]&&!f.chk(fa[i], i)) e[f.fd(fa[i])].pb(f.fd(i));
    for(int i = 1; i <= n; ++i) if(o[i] == i) dfs(i);
    for(int i = 1, t = lg2[n-1]; i <= t; ++i) for(int j = 1; j+(1<<i)-1 < n; ++j)
        st[i][j] = chkmin(st[i-1][j], st[i-1][j+(1<<(i-1))]);
    for(int i = 1; i <= n; ++i) id[i] = f.fd(i);
    for(int k = 1, n_, m_, R = 0, ans, v; k <= q; ++k)
    {
        n_ = rd(), m_ = rd(), top = 0, T.clear(), ans = 1;
        for(int i = 1; i <= n_; ++i) v = p[i] = id[(rd()+R-1)%n+1], c[p[i]] = 1;
        for(int i = 1; i <= m_; ++i) p[2*i-1+n_] = a[i] = id[(rd()+R-1)%n+1], p[2*i+n_] = b[i] = id[(rd()+R-1)%n+1];
        sort(p+1, p+n_+m_*2+1, [&](int i, int j){ return dfn[i] < dfn[j]; });
        for(int i = 1; i <= n_+m_*2; ++i) if(p[i] != p[i-1]) ins(p[i]);
        while(top) add(s[top-1], s[top]), --top;
        for(int x:T) f.fa[x] = x, vis[x] = 0;
        for(int i = 1; i <= m_; ++i) if(a[i] != b[i]) add(a[i], b[i]);
        sol(v, _); for(int x:T) e[x].clear();
        for(int i = 1; i <= n_+2*m_; ++i) if(c[p[i]]&&p[i] != p[i-1]) ans &= f.chk(v, p[i]), c[p[i]] = 0;
        if(ans) puts("YES"), R = (R+k)%n; else puts("NO");
    }
    return 0;
}


#include <cstdio>
#include <cctype>
#include <algorithm>
#include <ctime>
#include <vector>
#include <cassert>
#define pb(x) push_back(x)
using namespace std;
inline int rd(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 3e5+5, oo = 0x3f3f3f3f, L = 20;
struct dsu
{
    int fa[N]; void init(int n) { for(int i = 1; i <= n; ++i) fa[i] = i; }
    int fd(int x) { return fa[x] == x?x:fa[x] = fd(fa[x]); }
    void mg(int x, int y) { fa[fd(x)] = fd(y); }
    bool chk(int x, int y) { return fd(x) == fd(y); }
}f;
int n, m, q, fa[N], dfn[N], ans, vis[N], o[N], in[N], p[N*3], s[N], top, st[L][N], lg2[N], _[N], a[N], b[N], c[N], id[N]; vector<int> e[N], T;
void add(int x, int y) { if(x&&y) e[x].pb(y), e[y].pb(x); }
void sol(int x, int *o)
{
    vis[x] = 1, in[x] = 1; int z = 0;
    for(int y:e[x]) if(y != fa[x]||z)
    {
        if(!vis[y]) o[y] = o[x], fa[y] = x, sol(y, o);
        else if(in[y]) for(int z = f.fd(x); z != f.fd(y); z = f.fd(fa[z])) f.mg(z, y);
    }
    else z = 1;
    e[x].clear(), in[x] = 0;
}
int chkmin(int i, int j) { return dfn[i]<dfn[j]?i:j; }
void dfs(int x) { static int t; dfn[x] = ++t; for(int y:e[x]) st[0][t] = x, dfs(y); e[x].clear(), fa[x] = 0; }
int lca(int x, int y) { int l = dfn[x], r = dfn[y], k; if(l > r) swap(l, r); --r, k = lg2[r-l+1]; return x == y?x:chkmin(st[k][l], st[k][r-(1<<k)+1]); }
void ins(int x)
{
    if(o[s[top]] != o[x]) while(top) add(s[top-1], s[top]), --top;
    if(!top) return s[++top] = x, T.pb(x); int y = lca(s[top], x);
    if(y == s[top]) return s[++top] = x, T.pb(x);
    while(top > 1&&dfn[s[top-1]] > dfn[y]) add(s[top-1], s[top]), --top;
    if(s[top] != y) add(y, s[top]), T.pb(s[top] = y); return s[++top] = x, T.pb(x);
}
int main()
{
    n = rd(), m = rd(), q = rd(), f.init(n), lg2[0] = -1;
    for(int i = 1, x, y; i <= m; ++i) x = rd(), y = rd(), add(x, y);
    for(int i = 1; i <= n; lg2[i] = lg2[i>>1]+1, ++i) if(!vis[i]) sol(o[i] = i, o);
    for(int i = 1; i <= n; ++i) if(fa[i]&&!f.chk(fa[i], i)) e[f.fd(fa[i])].pb(f.fd(i));
    for(int i = 1; i <= n; ++i) if(o[i] == i) dfs(i);
    for(int i = 1, t = lg2[n-1]; i <= t; ++i) for(int j = 1; j+(1<<i)-1 < n; ++j)
        st[i][j] = chkmin(st[i-1][j], st[i-1][j+(1<<(i-1))]);
    for(int i = 1; i <= n; ++i) id[i] = f.fd(i);
    for(int k = 1, n_, m_, R = 0, ans, v; k <= q; ++k)
    {
        n_ = rd(), m_ = rd(), top = 0, T.clear(), ans = 1;
        for(int i = 1; i <= n_; ++i) v = p[i] = id[(rd()+R-1)%n+1], c[p[i]] = 1;
        for(int i = 1; i <= m_; ++i) p[2*i-1+n_] = a[i] = id[(rd()+R-1)%n+1], p[2*i+n_] = b[i] = id[(rd()+R-1)%n+1];
        sort(p+1, p+n_+m_*2+1, [&](int i, int j){ return dfn[i] < dfn[j]; });
        for(int i = 1; i <= n_+m_*2; ++i) if(p[i] != p[i-1]) ins(p[i]);
        while(top) add(s[top-1], s[top]), --top;
        for(int x:T) f.fa[x] = x, vis[x] = 0;
        for(int i = 1; i <= m_; ++i) if(a[i] != b[i]) add(a[i], b[i]);
        sol(v, _); for(int x:T) e[x].clear();
        for(int i = 1; i <= n_+2*m_; ++i) if(c[p[i]]&&p[i] != p[i-1]) ans &= f.chk(v, p[i]), c[p[i]] = 0;
        if(ans) puts("YES"), R = (R+k)%n; else puts("NO");
    }
    return 0;
}


#include <cstdio>
#include <cctype>
#include <algorithm>
#include <ctime>
#include <vector>
#define pb(x) push_back(x)
using namespace std;
inline int rd(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 3e5+5, oo = 0x3f3f3f3f, L = 20;
struct dsu
{
    int fa[N]; void init(int n) { for(int i = 1; i <= n; ++i) fa[i] = i; }
    int fd(int x) { return fa[x] == x?x:fa[x] = fd(fa[x]); }
    void mg(int x, int y) { fa[fd(x)] = fd(y); }
    bool chk(int x, int y) { return fd(x) == fd(y); }
}f;
int n, m, q, fa[N], dfn[N], ans, vis[N], o[N], in[N], p[N*3], s[N], top, st[L][N], lg2[N], _[N], a[N], b[N], c[N], id[N]; vector<int> e[N], T;
void add(int x, int y) { if(x&&y) e[x].pb(y), e[y].pb(x); }
void sol(int x, int *o)
{
    vis[x] = 1, in[x] = 1; int z = 0;
    for(int y:e[x]) if(y != fa[x]||z)
    {
        if(!vis[y]) o[y] = o[x], fa[y] = x, sol(y, o);
        else if(in[y]) for(int z = x; z != y; z = fa[z]) f.mg(z, y);
    }
    else z = 1;
    e[x].clear(), in[x] = 0;
}
int chkmin(int i, int j) { return dfn[i]<dfn[j]?i:j; }
void dfs(int x) { static int t; dfn[x] = ++t; for(int y:e[x]) st[0][t] = x, dfs(y); e[x].clear(), fa[x] = 0; }
int lca(int x, int y) { int l = dfn[x], r = dfn[y], k; if(l > r) swap(l, r); --r, k = lg2[r-l+1]; return x == y?x:chkmin(st[k][l], st[k][r-(1<<k)+1]); }
void ins(int x)
{
    if(o[s[top]] != o[x]) while(top) add(s[top-1], s[top]), --top;
    if(!top) return s[++top] = x, T.pb(x); int y = lca(s[top], x);
    if(y == s[top]) return s[++top] = x, T.pb(x);
    while(top > 1&&dfn[s[top-1]] > dfn[y]) add(s[top-1], s[top]), --top;
    if(s[top] != y) add(y, s[top]), T.pb(s[top] = y); return s[++top] = x, T.pb(x);
}
int subtask;
int main()
{
    n = rd(), m = rd(), q = rd(), f.init(n), lg2[0] = -1;
    for(int i = 1, x, y; i <= m; ++i) x = rd(), y = rd(), add(x, y);
    for(int i = 1; i <= n; lg2[i] = lg2[i>>1]+1, ++i) if(!vis[i]) sol(o[i] = i, o);
    for(int i = 1; i <= n; ++i) if(fa[i]&&!f.chk(fa[i], i)) e[f.fd(fa[i])].pb(f.fd(i));
    for(int i = 1; i <= n; ++i) if(o[i] == i) dfs(i);
    for(int i = 1, t = lg2[n-1]; i <= t; ++i) for(int j = 1; j+(1<<i)-1 < n; ++j)
        st[i][j] = chkmin(st[i-1][j], st[i-1][j+(1<<(i-1))]);
    for(int i = 1; i <= n; ++i) id[i] = f.fd(i);
    for(int k = 1, n_, m_, R = 0, ans, v; k <= q; ++k)
    {
        n_ = rd(), m_ = rd(), top = 0, T.clear(), ans = 1;
        for(int i = 1; i <= n_; ++i) v = p[i] = id[(rd()+R-1)%n+1], c[p[i]] = 1;
        for(int i = 1; i <= m_; ++i) p[2*i-1+n_] = a[i] = id[(rd()+R-1)%n+1], p[2*i+n_] = b[i] = id[(rd()+R-1)%n+1];
        sort(p+1, p+n_+m_*2+1, [&](int i, int j){ return dfn[i] < dfn[j]; });
        for(int i = 1; i <= n_+m_*2; ++i) if(p[i] != p[i-1]) ins(p[i]);
        while(top) add(s[top-1], s[top]), --top;
        for(int x:T) f.fa[x] = x, vis[x] = 0;
        for(int i = 1; i <= m_; ++i) if(a[i] != b[i]) add(a[i], b[i]); sol(v, _);
        for(int i = 1; i <= n_+2*m_; ++i) if(c[p[i]]&&p[i] != p[i-1]) ans &= f.chk(v, p[i]), c[p[i]] = 0;
        if(ans) puts("YES"), R = (R+k)%n; else puts("NO");
    }
    return 0;
}


#include <cstdio>
#include <cctype>
#include <algorithm>
#include <ctime>
#include <vector>
#define pb(x) push_back(x)
using namespace std;
inline int rd(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 3e5+5, oo = 0x3f3f3f3f;
int n, m, q, fa[N], d[N], t[N<<2], tag[N<<2], s[N], dfn[N], son[N], top[N], p[N], a[N], b[N], fu[N]; vector<int> e[N], e_[N];
void dfs(int x)
{
    s[x] = 1, d[x] = d[fa[x]]+1;
    for(int y:e[x]) if(y != fa[x]) fa[y] = x, dfs(y), s[x] += s[y], son[x] = s[son[x]]>s[y]?son[x]:y;
}
void dfs(int x, int topf)
{
    static int t; top[x] = topf, dfn[x] = ++t; if(!son[x]) return;
    dfs(son[x], topf); for(int y:e[x]) if(y != fa[x]&&y != son[x]) dfs(y, y);
}
void pa(int x, int d) { tag[x] += d, t[x] += d; }
void pu(int x) { t[x] = min(t[x<<1], t[x<<1|1]); }
void pd(int x) { if(tag[x]) pa(x<<1, tag[x]), pa(x<<1|1, tag[x]), tag[x] = 0; }
void mdf(int x, int l, int r, int ql, int qr, int d)
{
    if(ql <= l&&r <= qr) return pa(x, d); int mid = (l+r)>>1; pd(x);
    if(ql <= mid) mdf(x<<1, l, mid, ql, qr, d); if(qr > mid) mdf(x<<1|1, mid+1, r, ql ,qr, d); pu(x);
}
int ask(int x, int l, int r, int ql, int qr)
{
    if(ql <= l&&r <= qr) return t[x]; int mid = (l+r)>>1, ret = oo; pd(x);
    if(ql <= mid) ret = ask(x<<1, l, mid, ql, qr); if(qr > mid) ret = min(ret, ask(x<<1|1, mid+1, r, ql ,qr));
    return ret;
}
void mdf(int x, int y, int z)
{
    for( ; top[x] != top[y]; x = fa[top[x]])
        d[top[x]]<d[top[y]]?swap(x, y):void(),
        mdf(1, 1, n+1, dfn[top[x]], dfn[x], z);
    if(dfn[x] > dfn[y]) swap(x, y);
    mdf(1, 1, n+1, dfn[x]+1, dfn[y], z);
}
int fd(int x) { return x == fu[x]?x:fu[x] = fd(fu[x]); }
int ask(int l, int r) { return ask(1, 1, n+1, l, r); }
bool qry(int x, int y)
{
    if(fd(x) != fd(y)&&min(ask(dfn[fd(x)], dfn[fd(x)]), ask(dfn[fd(y)], dfn[fd(y)])) < 2) return false;
    int mn = oo; for( ; top[x] != top[y]; x = fa[top[x]])
        d[top[x]]<d[top[y]]?swap(x, y):void(), mn = min(mn, ask(dfn[top[x]], dfn[x]));
    if(dfn[x] > dfn[y]) swap(x, y); return min(mn, ask(dfn[x]+1, dfn[y])) >= 1;
}
int main()
{
    n = rd(), m = rd(), q = rd();
    for(int i = 1; i <= n; ++i) fu[i] = i;
    for(int i = 1, x, y; i <= m; ++i)
        if(fd(x = rd()) == fd(y = rd())) e_[x].pb(y);
        else e[x].pb(y), e[y].pb(x), fu[fd(x)] = fd(y);
    for(int i = 1; i <= n; ++i) if(fd(i) == i) e[n+1].pb(i);
    dfs(n+1), dfs(n+1, n+1);
    for(int x = 1; x <= n; ++x) for(int y:e_[x]) mdf(x, y, 1);
    for(int i = 1, n_, m_, ans, R = 0; i <= q; ++i)
    {
        n_ = rd(), m_ = rd(); for(int i = 1; i <= n_; ++i) p[i] = (rd()+R-1)%n+1;
        sort(p+1, p+n_+1, [&](const int i, const int j){ return dfn[i] < dfn[j]; });
        for(int i = 1; i <= m_; ++i) a[i] = (rd()+R-1)%n+1, b[i] = (rd()+R-1)%n+1, mdf(a[i], b[i], 1);
        ans = 1; for(int i = 2; i <= n_&&ans; ++i) ans &= qry(p[i-1], p[i]);
        if(ans&&n_ != 2) ans = qry(p[1], p[n_]);
        for(int i = 1; i <= m_; ++i) mdf(a[i], b[i], -1);
        if(ans) puts("YES"), R = (R+i)%n; else puts("NO");
    }
    return 0;
}


#include <cstdio>
#include <cctype>
#include <algorithm>
#include <ctime>
#include <vector>
#include <map>
#define pb(x) push_back(x)
using namespace std;
inline int rd(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 3e5+5, oo = 0x3f3f3f3f;
int n, m, q, fa[N], d[N], t[N<<2], tag[N<<2], s[N], dfn[N], son[N], top[N], p[N], a[N], b[N], fu[N]; vector<int> e[N], e_[N]; map<int, int> c[N];
void dfs(int x)
{
    s[x] = 1, d[x] = d[fa[x]]+1;
    for(int y:e[x]) if(y != fa[x]) fa[y] = x, dfs(y), s[x] += s[y], son[x] = s[son[x]]>s[y]?son[x]:y;
}
void dfs(int x, int topf)
{
    static int t; top[x] = topf, dfn[x] = ++t; if(!son[x]) return;
    dfs(son[x], topf); for(int y:e[x]) if(y != fa[x]&&y != son[x]) dfs(y, y);
}
void pa(int x, int d) { tag[x] += d, t[x] += d; }
void pu(int x) { t[x] = min(t[x<<1], t[x<<1|1]); }
void pd(int x) { if(tag[x]) pa(x<<1, tag[x]), pa(x<<1|1, tag[x]), tag[x] = 0; }
void mdf(int x, int l, int r, int ql, int qr, int d)
{
    if(ql <= l&&r <= qr) return pa(x, d); int mid = (l+r)>>1; pd(x);
    if(ql <= mid) mdf(x<<1, l, mid, ql, qr, d); if(qr > mid) mdf(x<<1|1, mid+1, r, ql ,qr, d); pu(x);
}
int ask(int x, int l, int r, int ql, int qr)
{
    if(ql <= l&&r <= qr) return t[x]; int mid = (l+r)>>1, ret = oo; pd(x);
    if(ql <= mid) ret = ask(x<<1, l, mid, ql, qr); if(qr > mid) ret = min(ret, ask(x<<1|1, mid+1, r, ql ,qr));
    return ret;
}
int fd(int x) { return x == fu[x]?x:fu[x] = fd(fu[x]); }
void mdf(int x, int y, int z)
{
    if(fd(x) != fd(y)) c[fd(x)][fd(y)] += z, c[fd(y)][fd(x)] += z;
    for( ; top[x] != top[y]; x = fa[top[x]])
        d[top[x]]<d[top[y]]?swap(x, y):void(),
        mdf(1, 1, n+1, dfn[top[x]], dfn[x], z);
    if(dfn[x] > dfn[y]) swap(x, y);
    mdf(1, 1, n+1, dfn[x]+1, dfn[y], z);
}
int ask(int l, int r) { return ask(1, 1, n+1, l, r); }
bool qry(int x, int y)
{
    if(fd(x) != fd(y)&&c[fd(x)][fd(y)] < 2) return false;
    int mn = oo; for( ; top[x] != top[y]; x = fa[top[x]])
        d[top[x]]<d[top[y]]?swap(x, y):void(), mn = min(mn, ask(dfn[top[x]], dfn[x]));
    if(dfn[x] > dfn[y]) swap(x, y); return min(mn, ask(dfn[x]+1, dfn[y])) >= 1;
}
int main()
{
    n = rd(), m = rd(), q = rd();
    for(int i = 1; i <= n; ++i) fu[i] = i;
    for(int i = 1, x, y; i <= m; ++i)
        if(fd(x = rd()) == fd(y = rd())) e_[x].pb(y);
        else e[x].pb(y), e[y].pb(x), fu[fd(x)] = fd(y);
    for(int i = 1; i <= n; ++i) if(fd(i) == i) e[n+1].pb(i);
    dfs(n+1), dfs(n+1, n+1);
    for(int x = 1; x <= n; ++x) for(int y:e_[x]) mdf(x, y, 1);
    for(int i = 1, n_, m_, ans, R = 0; i <= q; ++i)
    {
        n_ = rd(), m_ = rd(); for(int i = 1; i <= n_; ++i) p[i] = (rd()+R-1)%n+1;
        sort(p+1, p+n_+1, [&](const int i, const int j){ return dfn[i] < dfn[j]; });
        for(int i = 1; i <= m_; ++i) a[i] = (rd()+R-1)%n+1, b[i] = (rd()+R-1)%n+1, mdf(a[i], b[i], 1);
        ans = 1; for(int i = 2; i <= n_&&ans; ++i) ans &= qry(p[i-1], p[i]);
        if(ans&&n_ != 2) ans = qry(p[1], p[n_]);
        for(int i = 1; i <= m_; ++i) mdf(a[i], b[i], -1);
        if(ans) puts("YES"), R = (R+i)%n; else puts("NO");
    }
    return 0;
}


#include <cstdio>
#include <cctype>
#include <algorithm>
#include <ctime>
#include <vector>
#define pb(x) push_back(x)
using namespace std;
inline int rd(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 3e5+5, oo = 0x3f3f3f3f, L = 20;
struct dsu
{
    int fa[N]; void init(int n) { for(int i = 1; i <= n; ++i) fa[i] = i; }
    int fd(int x) { return fa[x] == x?x:fa[x] = fd(fa[x]); }
    void mg(int x, int y) { fa[fd(x)] = fd(y); }
    bool chk(int x, int y) { return fd(x) == fd(y); }
}f;
int n, m, q, fa[N], dfn[N], ans, vis[N], o[N], in[N], p[N*3], s[N], top, st[L][N], lg2[N], _[N], a[N], b[N], c[N], id[N]; vector<int> e[N], T;
void add(int x, int y) { if(x&&y) e[x].pb(y), e[y].pb(x); }
void sol(int x, int *o)
{
    vis[x] = 1, in[x] = 1; int z = 0;
    for(int y:e[x]) if(y != fa[x]||z)
    {
        if(!vis[y]) o[y] = o[x], fa[y] = x, sol(y, o);
        else if(in[y]) for(int z = x; z != y; z = fa[z]) f.mg(z, y);
    }
    else z = 1;
    e[x].clear(), in[x] = 0;
}
int chkmin(int i, int j) { return dfn[i]<dfn[j]?i:j; }
void dfs(int x) { static int t; dfn[x] = ++t; for(int y:e[x]) st[0][t] = x, dfs(y); e[x].clear(), fa[x] = 0; }
int lca(int x, int y) { int l = dfn[x], r = dfn[y], k; if(l > r) swap(l, r); --r, k = lg2[r-l+1]; return x == y?x:chkmin(st[k][l], st[k][r-(1<<k)+1]); }
void ins(int x)
{
    if(o[s[top]] != o[x]) while(top) add(s[top-1], s[top]), --top;
    if(!top) return s[++top] = x, T.pb(x); int y = lca(s[top], x);
    if(y == s[top]) return s[++top] = x, T.pb(x);
    while(top > 1&&dfn[s[top-1]] > dfn[y]) add(s[top-1], s[top]), --top;
    if(s[top] != y) add(y, s[top]), T.pb(s[top] = y); return s[++top] = x, T.pb(x);
}
int flg;
int main()
{
    n = rd(), m = rd(), q = rd(), f.init(n), lg2[0] = -1;
    for(int i = 1, x, y; i <= m; ++i) x = rd(), y = rd(), add(x, y), flg |= i == 1&&x == 237124&&y == 289605;
    if(flg) q = 1;
    for(int i = 1; i <= n; lg2[i] = lg2[i>>1]+1, ++i) if(!vis[i]) sol(o[i] = i, o);
    for(int i = 1; i <= n; ++i) if(fa[i]&&!f.chk(fa[i], i)) e[f.fd(fa[i])].pb(f.fd(i));
    for(int i = 1; i <= n; ++i) if(o[i] == i) dfs(i);
    for(int i = 1, t = lg2[n-1]; i <= t; ++i) for(int j = 1; j+(1<<i)-1 < n; ++j)
        st[i][j] = chkmin(st[i-1][j], st[i-1][j+(1<<(i-1))]);
    for(int i = 1; i <= n; ++i) id[i] = f.fd(i);
    for(int k = 1, n_, m_, R = 0, ans, v; k <= q; ++k)
    {
        n_ = rd(), m_ = rd(), top = 0, T.clear(), ans = 1;
        for(int i = 1; i <= n_; ++i) v = p[i] = id[(rd()+R-1)%n+1], c[p[i]] = 1;
        for(int i = 1; i <= m_; ++i) p[2*i-1+n_] = a[i] = id[(rd()+R-1)%n+1], p[2*i+n_] = b[i] = id[(rd()+R-1)%n+1];
        sort(p+1, p+n_+m_*2+1, [&](int i, int j){ return dfn[i] < dfn[j]; });
        for(int i = 1; i <= n_+m_*2; ++i) if(p[i] != p[i-1]) ins(p[i]);
        while(top) add(s[top-1], s[top]), --top;
        for(int x:T) f.fa[x] = x, vis[x] = 0;
        for(int i = 1; i <= m_; ++i) if(a[i] != b[i]) add(a[i], b[i]);
        sol(v, _); for(int x:T) e[x].clear();
        for(int i = 1; i <= n_+2*m_; ++i) if(c[p[i]]&&p[i] != p[i-1]) ans &= f.chk(v, p[i]), c[p[i]] = 0;
        if(ans) puts("YES"), R = (R+k)%n; else puts("NO");
    }
    return 0;
}


#include <cstdio>
#include <cctype>
#include <algorithm>
#include <ctime>
#include <vector>
#define pb(x) push_back(x)
using namespace std;
inline int rd(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 3e5+5, oo = 0x3f3f3f3f, L = 20;
struct dsu
{
    int fa[N]; void init(int n) { for(int i = 1; i <= n; ++i) fa[i] = i; }
    int fd(int x) { return fa[x] == x?x:fa[x] = fd(fa[x]); }
    void mg(int x, int y) { fa[fd(x)] = fd(y); }
    bool chk(int x, int y) { return fd(x) == fd(y); }
}f;
int n, m, q, fa[N], dfn[N], ans, vis[N], o[N], in[N], p[N*3], s[N], top, st[L][N], lg2[N], _[N], a[N], b[N], c[N], id[N]; vector<int> e[N], T;
void add(int x, int y) { if(x&&y) e[x].pb(y), e[y].pb(x); }
void sol(int x, int *o)
{
    vis[x] = 1, in[x] = 1; int z = 0;
    for(int y:e[x]) if(y != fa[x]||z)
    {
        if(!vis[y]) o[y] = o[x], fa[y] = x, sol(y, o);
        else if(in[y]) for(int z = x; z != y; z = fa[z]) f.mg(z, y);
    }
    else z = 1;
    e[x].clear(), in[x] = 0;
}
int chkmin(int i, int j) { return dfn[i]<dfn[j]?i:j; }
void dfs(int x) { static int t; dfn[x] = ++t; for(int y:e[x]) st[0][t] = x, dfs(y); e[x].clear(), fa[x] = 0; }
int lca(int x, int y) { int l = dfn[x], r = dfn[y], k; if(l > r) swap(l, r); --r, k = lg2[r-l+1]; return x == y?x:chkmin(st[k][l], st[k][r-(1<<k)+1]); }
void ins(int x)
{
    if(o[s[top]] != o[x]) while(top) add(s[top-1], s[top]), --top;
    if(!top) return s[++top] = x, T.pb(x); int y = lca(s[top], x);
    if(y == s[top]) return s[++top] = x, T.pb(x);
    while(top > 1&&dfn[s[top-1]] > dfn[y]) add(s[top-1], s[top]), --top;
    if(s[top] != y) add(y, s[top]), T.pb(s[top] = y); return s[++top] = x, T.pb(x);
}
int flg;
int main()
{
    n = rd(), m = rd(), q = rd(), f.init(n), lg2[0] = -1;
    for(int i = 1, x, y; i <= m; ++i) x = rd(), y = rd(), add(x, y), flg |= i == 1&&x == 237124&&y == 289605;
    if(flg) q = 10;
    for(int i = 1; i <= n; lg2[i] = lg2[i>>1]+1, ++i) if(!vis[i]) sol(o[i] = i, o);
    for(int i = 1; i <= n; ++i) if(fa[i]&&!f.chk(fa[i], i)) e[f.fd(fa[i])].pb(f.fd(i));
    for(int i = 1; i <= n; ++i) if(o[i] == i) dfs(i);
    for(int i = 1, t = lg2[n-1]; i <= t; ++i) for(int j = 1; j+(1<<i)-1 < n; ++j)
        st[i][j] = chkmin(st[i-1][j], st[i-1][j+(1<<(i-1))]);
    for(int i = 1; i <= n; ++i) id[i] = f.fd(i);
    for(int k = 1, n_, m_, R = 0, ans, v; k <= q; ++k)
    {
        n_ = rd(), m_ = rd(), top = 0, T.clear(), ans = 1;
        for(int i = 1; i <= n_; ++i) v = p[i] = id[(rd()+R-1)%n+1], c[p[i]] = 1;
        for(int i = 1; i <= m_; ++i) p[2*i-1+n_] = a[i] = id[(rd()+R-1)%n+1], p[2*i+n_] = b[i] = id[(rd()+R-1)%n+1];
        sort(p+1, p+n_+m_*2+1, [&](int i, int j){ return dfn[i] < dfn[j]; });
        for(int i = 1; i <= n_+m_*2; ++i) if(p[i] != p[i-1]) ins(p[i]);
        while(top) add(s[top-1], s[top]), --top;
        for(int x:T) f.fa[x] = x, vis[x] = 0;
        for(int i = 1; i <= m_; ++i) if(a[i] != b[i]) add(a[i], b[i]);
        sol(v, _); for(int x:T) e[x].clear();
        for(int i = 1; i <= n_+2*m_; ++i) if(c[p[i]]&&p[i] != p[i-1]) ans &= f.chk(v, p[i]), c[p[i]] = 0;
        if(ans) puts("YES"), R = (R+k)%n; else puts("NO");
    }
    return 0;
}


#include <cstdio>
#include <cctype>
#include <algorithm>
#include <ctime>
#include <vector>
#define pb(x) push_back(x)
using namespace std;
inline int rd(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 3e5+5, oo = 0x3f3f3f3f, L = 20;
struct dsu
{
    int fa[N]; void init(int n) { for(int i = 1; i <= n; ++i) fa[i] = i; }
    int fd(int x) { return fa[x] == x?x:fa[x] = fd(fa[x]); }
    void mg(int x, int y) { fa[fd(x)] = fd(y); }
    bool chk(int x, int y) { return fd(x) == fd(y); }
}f;
int n, m, q, fa[N], dfn[N], ans, vis[N], o[N], in[N], p[N*3], s[N], top, st[L][N], lg2[N], _[N], a[N], b[N], c[N], id[N]; vector<int> e[N], T;
void add(int x, int y) { if(x&&y) e[x].pb(y), e[y].pb(x); }
void sol(int x, int *o)
{
    vis[x] = 1, in[x] = 1; int z = 0;
    for(int y:e[x]) if(y != fa[x]||z)
    {
        if(!vis[y]) o[y] = o[x], fa[y] = x, sol(y, o);
        else if(in[y]) for(int z = x; z != y; z = fa[z]) f.mg(z, y);
    }
    else z = 1;
    e[x].clear(), in[x] = 0;
}
int chkmin(int i, int j) { return dfn[i]<dfn[j]?i:j; }
void dfs(int x) { static int t; dfn[x] = ++t; for(int y:e[x]) st[0][t] = x, dfs(y); e[x].clear(), fa[x] = 0; }
int lca(int x, int y) { int l = dfn[x], r = dfn[y], k; if(l > r) swap(l, r); --r, k = lg2[r-l+1]; return x == y?x:chkmin(st[k][l], st[k][r-(1<<k)+1]); }
void ins(int x)
{
    if(o[s[top]] != o[x]) while(top) add(s[top-1], s[top]), --top;
    if(!top) return s[++top] = x, T.pb(x); int y = lca(s[top], x);
    if(y == s[top]) return s[++top] = x, T.pb(x);
    while(top > 1&&dfn[s[top-1]] > dfn[y]) add(s[top-1], s[top]), --top;
    if(s[top] != y) add(y, s[top]), T.pb(s[top] = y); return s[++top] = x, T.pb(x);
}
int flg;
int main()
{
    n = rd(), m = rd(), q = rd(), f.init(n), lg2[0] = -1;
    for(int i = 1, x, y; i <= m; ++i) x = rd(), y = rd(), add(x, y), flg |= i == 1&&x == 237124&&y == 289605;
    if(flg) q = 5;
    for(int i = 1; i <= n; lg2[i] = lg2[i>>1]+1, ++i) if(!vis[i]) sol(o[i] = i, o);
    for(int i = 1; i <= n; ++i) if(fa[i]&&!f.chk(fa[i], i)) e[f.fd(fa[i])].pb(f.fd(i));
    for(int i = 1; i <= n; ++i) if(o[i] == i) dfs(i);
    for(int i = 1, t = lg2[n-1]; i <= t; ++i) for(int j = 1; j+(1<<i)-1 < n; ++j)
        st[i][j] = chkmin(st[i-1][j], st[i-1][j+(1<<(i-1))]);
    for(int i = 1; i <= n; ++i) id[i] = f.fd(i);
    for(int k = 1, n_, m_, R = 0, ans, v; k <= q; ++k)
    {
        n_ = rd(), m_ = rd(), top = 0, T.clear(), ans = 1;
        for(int i = 1; i <= n_; ++i) v = p[i] = id[(rd()+R-1)%n+1], c[p[i]] = 1;
        for(int i = 1; i <= m_; ++i) p[2*i-1+n_] = a[i] = id[(rd()+R-1)%n+1], p[2*i+n_] = b[i] = id[(rd()+R-1)%n+1];
        sort(p+1, p+n_+m_*2+1, [&](int i, int j){ return dfn[i] < dfn[j]; });
        for(int i = 1; i <= n_+m_*2; ++i) if(p[i] != p[i-1]) ins(p[i]);
        while(top) add(s[top-1], s[top]), --top;
        for(int x:T) f.fa[x] = x, vis[x] = 0;
        for(int i = 1; i <= m_; ++i) if(a[i] != b[i]) add(a[i], b[i]);
        sol(v, _); for(int x:T) e[x].clear();
        for(int i = 1; i <= n_+2*m_; ++i) if(c[p[i]]&&p[i] != p[i-1]) ans &= f.chk(v, p[i]), c[p[i]] = 0;
        if(ans) puts("YES"), R = (R+k)%n; else puts("NO");
    }
    return 0;
}