#include <bits/stdc++.h>
using namespace std;
const int Maxn=300005;
vector<int>e[Maxn],ne[Maxn];
vector<pair<int,int>>edge,nedge;
int bl[Maxn],vis[Maxn],dep[Maxn],f[Maxn][20],st[Maxn],ed[Maxn],scc;
namespace A{
	vector<pair<int,int>>E[Maxn];
	int dfn[Maxn],low[Maxn],tmp[Maxn],scc;
	void Tarjan(int x,int id){
		static int cnt,Stack[Maxn],top;
		dfn[x]=low[x]=++cnt;
		Stack[++top]=x;
		for(auto i:E[x]){
			int y,eid;tie(y,eid)=i;
			if(eid==id)continue;
			if(!dfn[y])Tarjan(y,eid),low[x]=min(low[x],low[y]);
			else low[x]=min(low[x],dfn[y]);
		}
		if(dfn[x]==low[x]){
			scc++;
			int t;
			do{
				t=Stack[top--];
				tmp[t]=scc;
			}while(t!=x);
		}
	}
	void solve(vector<int>V,vector<pair<int,int>>edge){
		scc=0;
		for(int i:V)dfn[i]=0,low[i]=0,tmp[i]=0,E[i].clear();
		/*puts("###########tarjan!!!");
		cout<<"node:";for(int i:V)cout<<i<<" ";cout<<"\n";
		cout<<"edge:\n";*/
		for(auto i:edge){
			static int cnt;
			/*cout<<i.first<<"=>"<<i.second<<"\n";*/
			if(i.first==i.second)continue;
			cnt++;
			E[i.first].emplace_back(i.second,cnt);
			E[i.second].emplace_back(i.first,cnt);
		}
		for(int i:V)
			if(!dfn[i])
				Tarjan(i,0);
		/*puts("bl:");
		for(int i:V)cout<<tmp[i]<<" ";cout<<"\n";
		puts("@@@@@@@@@@@");*/
	}
}
void dfs(int x,int fa){
	static int cnt;
	st[x]=++cnt;
	f[x][0]=fa;dep[x]=dep[fa]+1;
	for(int i=1;i<20;i++)f[x][i]=f[f[x][i-1]][i-1];
	for(int y:ne[x]){
		if(y==fa)continue;
		dfs(y,x);
	}
	ed[x]=cnt;
}
int lca(int x,int y){
	if(dep[x]<dep[y])swap(x,y);
	for(int i=19;~i;i--)
		if(dep[f[x][i]]>=dep[y])
			x=f[x][i];
	if(x==y)return x;
	for(int i=19;~i;i--)
		if(f[x][i]!=f[y][i])
			x=f[x][i],y=f[y][i];
	return f[x][0];
}
int main(){
	int n,m,q;scanf("%d%d%d",&n,&m,&q);
	st[0]=1;ed[0]=n;
	for(int i=1;i<=m;i++){
		int x,y;scanf("%d%d",&x,&y);
		if(x==y)continue;
		edge.emplace_back(x,y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	vector<int>a;
	for(int i=1;i<=n;i++)a.push_back(i);
	A::solve(a,edge);
	scc=A::scc;
	for(int i=1;i<=n;i++)bl[i]=A::tmp[i];
	for(auto i:edge){
		int x,y;tie(x,y)=i;
		x=bl[x],y=bl[y];
		if(x==y)continue;
		nedge.emplace_back(x,y);
		ne[x].push_back(y);
		ne[y].push_back(x);
	}
	for(int i=1;i<=scc;i++)
		if(!dep[i])dfs(i,0);
	for(int Q=1;Q<=q;Q++){
		static int cnt_yes=0,Stack[Maxn],top;
		int N,M;scanf("%d%d",&N,&M);
		vector<int>a,v;
		vector<pair<int,int>>tedge;
		auto rotate=[&](int x){
			x=(x+cnt_yes)%n;
			if(!x)x=n;
			return x;
		};
		auto cmp_dfn=[&](int x,int y){
			return st[x]<st[y];
		};
		auto In=[&](int x,int y){
			return st[y]<=st[x]&&ed[x]<=ed[y];
		};
		for(int i=1;i<=N;i++){
			int x;scanf("%d",&x);
			//cout<<"read:"<<x<<"\n";
			//cout<<"decrypt:"<<rotate(x)<<"\n";
			x=bl[rotate(x)];
			//cout<<"indexed:"<<x<<"\n";
			a.push_back(x);
			v.push_back(x);
		}
		for(int i=1;i<=M;i++){
			int x,y;scanf("%d%d",&x,&y);
			x=rotate(x);y=rotate(y);
			//cout<<"decrypt:"<<x<<" "<<y<<"\n";
			x=bl[x],y=bl[y];
			if(x==y)continue;
			a.push_back(x);
			a.push_back(y);
			tedge.emplace_back(x,y);
		}
		sort(a.begin(),a.end(),cmp_dfn);
		//cout<<"sorted\n";
		a.erase(unique(a.begin(),a.end()),a.end());
		//cout<<"uniqued\n";
		size_t sz=a.size();
		for(size_t i=0;i+1<sz;i++){
			int x=lca(a[i],a[i+1]);
			//cout<<"x="<<x<<"\n";
			if(x)a.push_back(x);
		}
		sort(a.begin(),a.end(),cmp_dfn);
		//cout<<"sorted\n";
		a.erase(unique(a.begin(),a.end()),a.end());
		//cout<<"uniqued\n";
		Stack[top=1]=0;
		for(auto i:a){
			//cout<<"i="<<i<<"\n";
			while(!In(i,Stack[top]))top--;
			if(Stack[top])tedge.emplace_back(i,Stack[top]);
			Stack[++top]=i;
		}
		//cout<<"constructed\n";
		A::solve(a,tedge);
		int chk=0;
		for(auto i:v)
			if(!chk)chk=A::tmp[i];
			else if(chk!=A::tmp[i])chk=-1;
		if(chk==-1)puts("NO");
		else puts("YES"),cnt_yes+=Q,cnt_yes%=n;
	}
	return 0;
}
/*
7 6 1

1 2
1 3
2 4
2 5
3 6
3 7

2 2
6 5
4 5
6 1
*/
/*
7 6 6

1 2
1 3
2 4
2 5
3 6
3 7

2 1
2 3
5 6

3 1
1 4 7
1 6

5 2
5 1 2 6 7
5 6
1 2

2 2
4 3
2 3
4 6

1 0
2

2 3
1 5
5 6
7 1
3 4
*/


#include<bits/stdc++.h>
#define maxn 900005
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)
using namespace std;

char cb[1<<16],*cs=cb,*ct=cb;
#define getc() (cs==ct&&(ct=(cs=cb)+fread(cb,1,1<<16,stdin),cs==ct)?0:*cs++)
void read(int &res){
	char ch;
	for(;!isdigit(ch=getc()););
	for(res=ch-'0';isdigit(ch=getc());res=res*10+ch-'0');
}

int n,m,q;
namespace Decode{
	int R=0;
	int rotate(int element)
	{
	   element=(element+R)%n;

	   if (element==0) {
	       element=n;
	   }

	   return element;
	}
};

int info[maxn],Prev[maxn<<1],to[maxn<<1],cnt_e=1;
void Node(int u,int v){ Prev[++cnt_e]=info[u],info[u]=cnt_e,to[cnt_e]=v; }

int dfn[maxn],low[maxn],tot,sta[maxn],c[maxn],scc;
void dfs0(int u,int ff){//ff is an edge
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=info[u],v;i;i=Prev[i]) if(i^ff){
		v = to[i];
		if(!dfn[v]) dfs0(v,i^1),low[u]=min(low[u],low[v]);
		else low[u]=min(low[u],dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			t=sta[sta[0]--];
			c[t] = scc;
		}
	}
}

vector<int>G[maxn];
int sz[maxn],tp[maxn],fa[maxn],son[maxn],dep[maxn],X[maxn],A[maxn],B[maxn],st[maxn];
void dfs1(int u,int ff){
	dep[u] = dep[fa[u] = ff] + (sz[u] = 1);
	st[u] = ++tot;
	for(int v:G[u])
		if(v!=ff)
			dfs1(v,u),sz[u]+=sz[v],(sz[son[u]]<sz[v]) && (son[u]=v);
}
void dfs2(int u,int ff){
	if(son[u]) tp[son[u]] = tp[u] , dfs2(son[u],u);
	for(int v:G[u]) if(v!=ff && v!= son[u])
		dfs2(tp[v]=v,u);
}
int Lca(int u,int v){
	for(;tp[u]^tp[v];u=fa[tp[u]])
		if(dep[tp[u]] < dep[tp[v]])
			swap(u,v);
	return dep[u] < dep[v] ? u : v;
}

int fir[maxn],nxt[maxn<<4],tar[maxn<<4],cnte=1;
void add(int u,int v){ nxt[++cnte] = fir[u] , fir[u] = cnte , tar[cnte] = v;}
bool cmp(const int &u,const int &v){ return st[u] < st[v]; }

int bl[maxn];
void dfs3(int u,int ff){
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=fir[u],v;i;i=nxt[i]) if(i ^ ff){
		v = tar[i];
		if(!dfn[v]) dfs3(v,i^1) , low[u] = min(low[u] , low[v]);
		else low[u] = min(low[u] , dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			bl[t=sta[sta[0]--]] = scc;
		}
	}
}

int main(){]
	read(n),read(m),read(q);
	rep(i,1,m){
		int u,v;read(u),read(v);
		Node(u,v),Node(v,u);
	}
	rep(i,1,n) if(!dfn[i]) dfs0(i,0);
	memset(dfn,0,sizeof dfn);
	memset(low,0,sizeof low);
	tot = 0;
	rep(i,1,n) for(int j=info[i],v;j;j=Prev[j])
		if(c[i] ^ c[to[j]])
			G[c[i]].push_back(c[to[j]]),
			G[c[to[j]]].push_back(c[i]);
	rep(i,1,scc) if(!fa[i])
		dfs1(i,0),dfs2(tp[i]=i,0);
	tot = scc = 0;
	for(int V,E;q--;){
		read(V),read(E);
		static int ar[maxn << 3]={} , pt[maxn] , st[maxn] , tp=0;
		rep(i,1,V) read(X[i]),X[i]=Decode::rotate(X[i]),ar[++ar[0]] = c[X[i]];
		rep(i,1,E){
			read(A[i]),read(B[i]);
			A[i]=Decode::rotate(A[i]);
			B[i]=Decode::rotate(B[i]);
			ar[++ar[0]] = c[A[i]] , ar[++ar[0]] = c[B[i]];
			add(c[A[i]],c[B[i]]),add(c[B[i]],c[A[i]]);
		}
		sort(ar+1,ar+1+ar[0],cmp);
		ar[0]=unique(ar+1,ar+1+ar[0])-ar-1;
		rep(i,1,ar[0]){
			if(tp){
				int t = Lca(st[tp] , ar[i]) , p = 0;
				if(!t){
					for(;tp;p=st[tp--])
						if(p)
							add(p,st[tp]),add(st[tp],p);
				}
				else{
					for(;tp && dep[st[tp]] > dep[t];p=st[tp--])
						if(p)
							add(st[tp],p),add(p,st[tp]);
					if(st[tp] ^ t) st[++tp] = pt[++pt[0]] = t;
					if(p) add(st[tp],p) , add(p,st[tp]);
				}
			}
			st[++tp] = pt[++pt[0]] = ar[i];
		}
		int rt=0;
		for(;tp;rt=st[tp--])
			if(rt)
				add(rt,st[tp]),add(st[tp],rt);
		rep(i,1,pt[0]) if(!dfn[pt[i]])
			dfs3(pt[i],0);
		int hp = bl[c[X[1]]];
		rep(i,1,V)
			if(bl[c[X[i]]] != hp){
				hp = -1;
				break;
			}
		static int T = 0;
		++T;
		if(hp == -1) puts("NO");
		else puts("YES") , (Decode::R+=T) %= n;
		rep(i,1,pt[0]) fir[pt[i]] = dfn[pt[i]] = low[pt[i]] = bl[pt[i]] = 0;
		ar[0] = pt[0] = tot = tp = scc = 0;
		cnte = 1;
	}
}


#include<bits/stdc++.h>
#define maxn 900005
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)
using namespace std;

char cb[1<<16],*cs=cb,*ct=cb;
#define getc() (cs==ct&&(ct=(cs=cb)+fread(cb,1,1<<16,stdin),cs==ct)?0:*cs++)
void read(int &res){
	char ch;
	for(;!isdigit(ch=getc()););
	for(res=ch-'0';isdigit(ch=getc());res=res*10+ch-'0');
}

int n,m,q;
namespace Decode{
	int R=0;
	int rotate(int element)
	{
	   element=(element+R)%n;

	   if (element==0) {
	       element=n;
	   }

	   return element;
	}
};

int info[maxn],Prev[maxn<<1],to[maxn<<1],cnt_e=1;
void Node(int u,int v){ Prev[++cnt_e]=info[u],info[u]=cnt_e,to[cnt_e]=v; }

int dfn[maxn],low[maxn],tot,sta[maxn],c[maxn],scc;
void dfs0(int u,int ff){//ff is an edge
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=info[u],v;i;i=Prev[i]) if(i^ff){
		v = to[i];
		if(!dfn[v]) dfs0(v,i^1),low[u]=min(low[u],low[v]);
		else low[u]=min(low[u],dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			t=sta[sta[0]--];
			c[t] = scc;
		}
	}
}

vector<int>G[maxn];
int sz[maxn],tp[maxn],fa[maxn],son[maxn],dep[maxn],X[maxn],A[maxn],B[maxn],st[maxn];
void dfs1(int u,int ff){
	dep[u] = dep[fa[u] = ff] + (sz[u] = 1);
	st[u] = ++tot;
	for(int v:G[u])
		if(v!=ff)
			dfs1(v,u),sz[u]+=sz[v],(sz[son[u]]<sz[v]) && (son[u]=v);
}
void dfs2(int u,int ff){
	if(son[u]) tp[son[u]] = tp[u] , dfs2(son[u],u);
	for(int v:G[u]) if(v!=ff && v!= son[u])
		dfs2(tp[v]=v,u);
}
int Lca(int u,int v){
	for(;tp[u]^tp[v];u=fa[tp[u]])
		if(dep[tp[u]] < dep[tp[v]])
			swap(u,v);
	return dep[u] < dep[v] ? u : v;
}

int fir[maxn],nxt[maxn<<4],tar[maxn<<4],cnte=1;
void add(int u,int v){ nxt[++cnte] = fir[u] , fir[u] = cnte , tar[cnte] = v;}
bool cmp(const int &u,const int &v){ return st[u] < st[v]; }

int bl[maxn];
void dfs3(int u,int ff){
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=fir[u],v;i;i=nxt[i]) if(i ^ ff){
		v = tar[i];
		if(!dfn[v]) dfs3(v,i^1) , low[u] = min(low[u] , low[v]);
		else low[u] = min(low[u] , dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			bl[t=sta[sta[0]--]] = scc;
		}
	}
}

int main(){

//	freopen("1.in","r",stdin);

	read(n),read(m),read(q);
	rep(i,1,m){
		int u,v;read(u),read(v);
		Node(u,v),Node(v,u);
	}
	rep(i,1,n) if(!dfn[i]) dfs0(i,0);
	memset(dfn,0,sizeof dfn);
	memset(low,0,sizeof low);
	tot = 0;
	rep(i,1,n) for(int j=info[i],v;j;j=Prev[j])
		if(c[i] ^ c[to[j]])
			G[c[i]].push_back(c[to[j]]),
			G[c[to[j]]].push_back(c[i]);
	rep(i,1,scc) if(!fa[i])
		dfs1(i,0),dfs2(tp[i]=i,0);
	tot = scc = 0;
	for(int V,E;q--;){
		read(V),read(E);
		static int ar[maxn << 3]={} , pt[maxn] , st[maxn] , tp=0;
		rep(i,1,V) read(X[i]),X[i]=Decode::rotate(X[i]),ar[++ar[0]] = c[X[i]];
		rep(i,1,E){
			read(A[i]),read(B[i]);
			A[i]=Decode::rotate(A[i]);
			B[i]=Decode::rotate(B[i]);
			ar[++ar[0]] = c[A[i]] , ar[++ar[0]] = c[B[i]];
			add(c[A[i]],c[B[i]]),add(c[B[i]],c[A[i]]);
		}
		sort(ar+1,ar+1+ar[0],cmp);
		ar[0]=unique(ar+1,ar+1+ar[0])-ar-1;
		rep(i,1,ar[0]){
			if(tp){
				int t = Lca(st[tp] , ar[i]) , p = 0;
				if(!t){
					for(;tp;p=st[tp--])
						if(p)
							add(p,st[tp]),add(st[tp],p);
				}
				else{
					for(;tp && dep[st[tp]] > dep[t];p=st[tp--])
						if(p)
							add(st[tp],p),add(p,st[tp]);
					if(st[tp] ^ t) st[++tp] = pt[++pt[0]] = t;
					if(p) add(st[tp],p) , add(p,st[tp]);
				}
			}
			st[++tp] = pt[++pt[0]] = ar[i];
		}
		int rt=0;
		for(;tp;rt=st[tp--])
			if(rt)
				add(rt,st[tp]),add(st[tp],rt);
		rep(i,1,pt[0]) if(!dfn[pt[i]])
			dfs3(pt[i],0);
		set<int>hp;
		rep(i,1,V)
			hp.insert(bl[c[X[i]]]);
		static int T = 0;
		++T;
		if(hp.size() > 1) puts("NO");
		else puts("YES") , (Decode::R+=T) %= n;
		rep(i,1,pt[0]) fir[pt[i]] = dfn[pt[i]] = low[pt[i]] = bl[pt[i]] = 0;
		ar[0] = pt[0] = tot = tp = scc = 0;
		cnte = 1;
	}
}


#include<bits/stdc++.h>
#define maxn 900005
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)
using namespace std;

char cb[1<<16],*cs=cb,*ct=cb;
#define getc() (cs==ct&&(ct=(cs=cb)+fread(cb,1,1<<16,stdin),cs==ct)?0:*cs++)
void read(int &res){
	char ch;
	for(;!isdigit(ch=getc()););
	for(res=ch-'0';isdigit(ch=getc());res=res*10+ch-'0');
}

int n,m,q;
namespace Decode{
	int R=0;
	int rotate(int element)
	{
	   element=(element+R)%n;

	   if (element==0) {
	       element=n;
	   }

	   return element;
	}
};

int info[maxn],Prev[maxn<<1],to[maxn<<1],cnt_e=1;
void Node(int u,int v){ Prev[++cnt_e]=info[u],info[u]=cnt_e,to[cnt_e]=v; }

int dfn[maxn],low[maxn],tot,sta[maxn],c[maxn],scc;
void dfs0(int u,int ff){//ff is an edge
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=info[u],v;i;i=Prev[i]) if(i^ff){
		v = to[i];
		if(!dfn[v]) dfs0(v,i^1),low[u]=min(low[u],low[v]);
		else low[u]=min(low[u],dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			t=sta[sta[0]--];
			c[t] = scc;
		}
	}
}

vector<int>G[maxn];
int sz[maxn],tp[maxn],fa[maxn],son[maxn],dep[maxn],X[maxn],A[maxn],B[maxn],st[maxn];
void dfs1(int u,int ff){
	dep[u] = dep[fa[u] = ff] + (sz[u] = 1);
	st[u] = ++tot;
	for(int v:G[u])
		if(v!=ff)
			dfs1(v,u),sz[u]+=sz[v],(sz[son[u]]<sz[v]) && (son[u]=v);
}
void dfs2(int u,int ff){
	if(son[u]) tp[son[u]] = tp[u] , dfs2(son[u],u);
	for(int v:G[u]) if(v!=ff && v!= son[u])
		dfs2(tp[v]=v,u);
}
int Lca(int u,int v){
	for(;tp[u]^tp[v];u=fa[tp[u]])
		if(dep[tp[u]] < dep[tp[v]])
			swap(u,v);
	return dep[u] < dep[v] ? u : v;
}

int fir[maxn],nxt[maxn<<4],tar[maxn<<4],cnte=1;
void add(int u,int v){ nxt[++cnte] = fir[u] , fir[u] = cnte , tar[cnte] = v;}
bool cmp(const int &u,const int &v){ return st[u] < st[v]; }

int bl[maxn];
void dfs3(int u,int ff){
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=fir[u],v;i;i=nxt[i]) if(i ^ ff){
		v = tar[i];
		if(!dfn[v]) dfs3(v,i^1) , low[u] = min(low[u] , low[v]);
		else low[u] = min(low[u] , dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			bl[t=sta[sta[0]--]] = scc;
		}
	}
}

int main(){

	read(n),read(m),read(q);
	rep(i,1,m){
		int u,v;read(u),read(v);
		Node(u,v),Node(v,u);
	}
	rep(i,1,n) if(!dfn[i]) dfs0(i,0);
	memset(dfn,0,sizeof dfn);
	memset(low,0,sizeof low);
	tot = 0;
	rep(i,1,n) for(int j=info[i],v;j;j=Prev[j])
		if(c[i] ^ c[to[j]])
			G[c[i]].push_back(c[to[j]]);
	rep(i,1,scc) if(!fa[i])
		dfs1(i,0),dfs2(tp[i]=i,0);
	tot = scc = 0;
	for(int V,E;q--;){
		read(V),read(E);
		static int ar[maxn << 3]={} , pt[maxn] , st[maxn] , tp=0;
		rep(i,1,V) read(X[i]),X[i]=Decode::rotate(X[i]),ar[++ar[0]] = c[X[i]];
		rep(i,1,E){
			read(A[i]),read(B[i]);
			A[i]=Decode::rotate(A[i]);
			B[i]=Decode::rotate(B[i]);
			if(c[A[i]] ^ c[B[i]])
				ar[++ar[0]] = c[A[i]] , ar[++ar[0]] = c[B[i]],
				add(c[A[i]],c[B[i]]),add(c[B[i]],c[A[i]]);
		}
		sort(ar+1,ar+1+ar[0],cmp);
		ar[0]=unique(ar+1,ar+1+ar[0])-ar-1;
		rep(i,1,ar[0]){
			if(tp){
				int t = Lca(st[tp] , ar[i]) , p = 0;
				if(!t){
					for(;tp;p=st[tp--])
						if(p)
							add(p,st[tp]),add(st[tp],p);
				}
				else{
					for(;tp && dep[st[tp]] > dep[t];p=st[tp--])
						if(p)
							add(st[tp],p),add(p,st[tp]);
					if(st[tp] ^ t) st[++tp] = pt[++pt[0]] = t;
					if(p) add(st[tp],p) , add(p,st[tp]);
				}
			}
			st[++tp] = pt[++pt[0]] = ar[i];
		}
		int rt=0;
		for(;tp;rt=st[tp--])
			if(rt)
				add(rt,st[tp]),add(st[tp],rt);
		rep(i,1,pt[0]) if(!dfn[pt[i]])
			dfs3(pt[i],0);
		int hp = bl[c[X[1]]];
		rep(i,1,V)
			if(bl[c[X[i]]] != hp){
				hp = -1;
				break;
			}
		static int T = 0;
		++T;
		if(hp == -1) puts("NO");
		else puts("YES") , (Decode::R+=T) %= n;
		rep(i,1,pt[0]) fir[pt[i]] = dfn[pt[i]] = low[pt[i]] = bl[pt[i]] = 0;
		ar[0] = pt[0] = tot = tp = scc = 0;
		cnte = 1;
	}
}


#include<bits/stdc++.h>
#define maxn 300005
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)
using namespace std;

char cb[1<<16],*cs=cb,*ct=cb;
#define getc() (cs==ct&&(ct=(cs=cb)+fread(cb,1,1<<16,stdin),cs==ct)?0:*cs++)
void read(int &res){
	char ch;
	for(;!isdigit(ch=getc()););
	for(res=ch-'0';isdigit(ch=getc());res=res*10+ch-'0');
}

int n,m,q;
namespace Decode{
	int R=0;
	int rotate(int element)
	{
	   element=(element+R)%n;

	   if (element==0) {
	       element=n;
	   }

	   return element;
	}
};

int info[maxn],Prev[maxn<<1],to[maxn<<1],cnt_e=1;
void Node(int u,int v){ Prev[++cnt_e]=info[u],info[u]=cnt_e,to[cnt_e]=v; }

int dfn[maxn],low[maxn],tot,sta[maxn],c[maxn],scc;
void dfs0(int u,int ff){//ff is an edge
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=info[u],v;i;i=Prev[i]) if(i^ff){
		v = to[i];
		if(!dfn[v]) dfs0(v,i^1),low[u]=min(low[u],low[v]);
		else low[u]=min(low[u],dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			t=sta[sta[0]--];
			c[t] = scc;
		}
	}
}

vector<int>G[maxn];
int sz[maxn],tp[maxn],fa[maxn],son[maxn],dep[maxn],X[maxn],A[maxn],B[maxn],st[maxn];
void dfs1(int u,int ff){
	dep[u] = dep[fa[u] = ff] + (sz[u] = 1);
	st[u] = ++tot;
	for(int v:G[u])
		if(v!=ff)
			dfs1(v,u),sz[u]+=sz[v],(sz[son[u]]<sz[v]) && (son[u]=v);
}
void dfs2(int u,int ff){
	if(son[u]) tp[son[u]] = tp[u] , dfs2(son[u],u);
	for(int v:G[u]) if(v!=ff && v!= son[u])
		dfs2(tp[v]=v,u);
}
int Lca(int u,int v){
	for(;tp[u]^tp[v];u=fa[tp[u]])
		if(dep[tp[u]] < dep[tp[v]])
			swap(u,v);
	return dep[u] < dep[v] ? u : v;
}

int fir[maxn],nxt[maxn<<1],tar[maxn<<1],cnte=1;
void add(int u,int v){ nxt[++cnte] = fir[u] , fir[u] = cnte , tar[cnte] = v;}
bool cmp(const int &u,const int &v){ return st[u] < st[v]; }

int bl[maxn];
void dfs3(int u,int ff){
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=fir[u],v;i;i=nxt[i]) if(i ^ ff){
		v = tar[i];
		if(!dfn[v]) dfs3(v,i^1) , low[u] = min(low[u] , low[v]);
		else low[u] = min(low[u] , dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			bl[t=sta[sta[0]--]] = scc;
		}
	}
}

int main(){
	read(n),read(m),read(q);
	rep(i,1,m){
		int u,v;read(u),read(v);
		Node(u,v),Node(v,u);
	}
	rep(i,1,n) if(!dfn[i]) dfs0(i,0);
	memset(dfn,0,sizeof dfn);
	memset(low,0,sizeof low);
	tot = 0;
	rep(i,1,n) for(int j=info[i],v;j;j=Prev[j])
		if(c[i] ^ c[to[j]])
			G[c[i]].push_back(c[to[j]]),
			G[c[to[j]]].push_back(c[i]);
	dfs1(1,0),dfs2(tp[1]=1,0);
	tot = scc = 0;
	for(int V,E;q--;){
		read(V),read(E);
		static int ar[maxn << 3]={} , pt[maxn] , st[maxn] , tp=0;
		rep(i,1,V) read(X[i]),X[i]=Decode::rotate(X[i]),ar[++ar[0]] = c[X[i]];
		rep(i,1,E){
			read(A[i]),read(B[i]);
			A[i]=Decode::rotate(A[i]);
			B[i]=Decode::rotate(B[i]);
			ar[++ar[0]] = c[A[i]] , ar[++ar[0]] = c[B[i]];
			add(c[A[i]],c[B[i]]),add(c[B[i]],c[A[i]]);
		}
		sort(ar+1,ar+1+ar[0],cmp);
		ar[0]=unique(ar+1,ar+1+ar[0])-ar-1;
		rep(i,1,ar[0]){
			if(tp){
				int t = Lca(st[tp] , ar[i]) , p = 0;
				for(;tp && dep[st[tp]] > dep[t];p=st[tp--])
					if(p)
						add(st[tp],p),add(p,st[tp]);
				if(st[tp] ^ t) st[++tp] = pt[++pt[0]] = t;
				if(p) add(st[tp],p) , add(p,st[tp]);
			}
			st[++tp] = pt[++pt[0]] = ar[i];
		}
		int rt=0;
		for(;tp;rt=st[tp--])
			if(rt)
				add(rt,st[tp]),add(st[tp],rt);
		rep(i,1,pt[0]) if(!dfn[pt[i]])
			dfs3(pt[i],0);
		set<int>hp;
		rep(i,1,V)
			hp.insert(bl[c[X[i]]]);
		static int T = 0;
		++T;
		if(hp.size() > 1) puts("NO");
		else puts("YES") , Decode::R+=T;
		rep(i,1,pt[0]) fir[pt[i]] = dfn[pt[i]] = low[pt[i]] = bl[pt[i]] = 0;
		ar[0] = pt[0] = tot = tp = scc = 0;
		cnte = 1;
	}
}


#include<bits/stdc++.h>
#define maxn 300005
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)
using namespace std;

char cb[1<<16],*cs=cb,*ct=cb;
#define getc() (cs==ct&&(ct=(cs=cb)+fread(cb,1,1<<16,stdin),cs==ct)?0:*cs++)
void read(int &res){
	char ch;
	for(;!isdigit(ch=getc()););
	for(res=ch-'0';isdigit(ch=getc());res=res*10+ch-'0');
}

int n,m,q;
namespace Decode{
	int R=0;
	int rotate(int element)
	{
	   element=(element+R)%n;

	   if (element==0) {
	       element=n;
	   }

	   return element;
	}
};

int info[maxn],Prev[maxn<<1],to[maxn<<1],cnt_e=1;
void Node(int u,int v){ Prev[++cnt_e]=info[u],info[u]=cnt_e,to[cnt_e]=v; }

int dfn[maxn],low[maxn],tot,sta[maxn],c[maxn],scc;
void dfs0(int u,int ff){//ff is an edge
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=info[u],v;i;i=Prev[i]) if(i^ff){
		v = to[i];
		if(!dfn[v]) dfs0(v,i^1),low[u]=min(low[u],low[v]);
		else low[u]=min(low[u],dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			t=sta[sta[0]--];
			c[t] = scc;
		}
	}
}

vector<int>G[maxn];
int sz[maxn],tp[maxn],fa[maxn],son[maxn],dep[maxn],X[maxn],A[maxn],B[maxn],st[maxn];
void dfs1(int u,int ff){
	dep[u] = dep[fa[u] = ff] + (sz[u] = 1);
	st[u] = ++tot;
	for(int v:G[u])
		if(v!=ff)
			dfs1(v,u),sz[u]+=sz[v],(sz[son[u]]<sz[v]) && (son[u]=v);
}
void dfs2(int u,int ff){
	if(son[u]) tp[son[u]] = tp[u] , dfs2(son[u],u);
	for(int v:G[u]) if(v!=ff && v!= son[u])
		dfs2(tp[v]=v,u);
}
int Lca(int u,int v){
	for(;tp[u]^tp[v];u=fa[tp[u]])
		if(dep[tp[u]] < dep[tp[v]])
			swap(u,v);
	return dep[u] < dep[v] ? u : v;
}

int fir[maxn],nxt[maxn<<1],tar[maxn<<1],cnte=1;
void add(int u,int v){ nxt[++cnte] = fir[u] , fir[u] = cnte , tar[cnte] = v;}
bool cmp(const int &u,const int &v){ return st[u] < st[v]; }

int bl[maxn];
void dfs3(int u,int ff){
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=fir[u],v;i;i=nxt[i]) if(i ^ ff){
		v = tar[i];
		if(!dfn[v]) dfs3(v,i^1) , low[u] = min(low[u] , low[v]);
		else low[u] = min(low[u] , dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			bl[t=sta[sta[0]--]] = scc;
		}
	}
}

int main(){

//	freopen("1.in","r",stdin);

	read(n),read(m),read(q);
	rep(i,1,m){
		int u,v;read(u),read(v);
		Node(u,v),Node(v,u);
	}
	rep(i,1,n) if(!dfn[i]) dfs0(i,0);
	memset(dfn,0,sizeof dfn);
	memset(low,0,sizeof low);
	tot = 0;
	rep(i,1,n) for(int j=info[i],v;j;j=Prev[j])
		if(c[i] ^ c[to[j]])
			G[c[i]].push_back(c[to[j]]),
			G[c[to[j]]].push_back(c[i]);
	rep(i,1,scc) if(!fa[i])
		dfs1(i,0),dfs2(tp[i]=i,0);
	tot = scc = 0;
	for(int V,E;q--;){
		read(V),read(E);
		static int ar[maxn << 3]={} , pt[maxn] , st[maxn] , tp=0;
		rep(i,1,V) read(X[i]),X[i]=Decode::rotate(X[i]),ar[++ar[0]] = c[X[i]];
		rep(i,1,E){
			read(A[i]),read(B[i]);
			A[i]=Decode::rotate(A[i]);
			B[i]=Decode::rotate(B[i]);
			ar[++ar[0]] = c[A[i]] , ar[++ar[0]] = c[B[i]];
			add(c[A[i]],c[B[i]]),add(c[B[i]],c[A[i]]);
		}
		sort(ar+1,ar+1+ar[0],cmp);
		ar[0]=unique(ar+1,ar+1+ar[0])-ar-1;
		rep(i,1,ar[0]){
			if(tp){
				int t = Lca(st[tp] , ar[i]) , p = 0;
				if(!t){
					for(;tp;p=st[tp--])
						if(p)
							add(p,st[tp]),add(st[tp],p);
				}
				else{
					for(;tp && dep[st[tp]] > dep[t];p=st[tp--])
						if(p)
							add(st[tp],p),add(p,st[tp]);
					if(st[tp] ^ t) st[++tp] = pt[++pt[0]] = t;
					if(p) add(st[tp],p) , add(p,st[tp]);
				}
			}
			st[++tp] = pt[++pt[0]] = ar[i];
		}
		int rt=0;
		for(;tp;rt=st[tp--])
			if(rt)
				add(rt,st[tp]),add(st[tp],rt);
		rep(i,1,pt[0]) if(!dfn[pt[i]])
			dfs3(pt[i],0);
		set<int>hp;
		rep(i,1,V)
			hp.insert(bl[c[X[i]]]);
		static int T = 0;
		++T;
		if(hp.size() > 1) puts("NO");
		else puts("YES") , (Decode::R+=T) %= n;
		rep(i,1,pt[0]) fir[pt[i]] = dfn[pt[i]] = low[pt[i]] = bl[pt[i]] = 0;
		ar[0] = pt[0] = tot = tp = scc = 0;
		cnte = 1;
	}
}


#include<bits/stdc++.h>
#define maxn 900005
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)
using namespace std;

char cb[1<<16],*cs=cb,*ct=cb;
#define getc() (cs==ct&&(ct=(cs=cb)+fread(cb,1,1<<16,stdin),cs==ct)?0:*cs++)
void read(int &res){
	char ch;
	for(;!isdigit(ch=getc()););
	for(res=ch-'0';isdigit(ch=getc());res=res*10+ch-'0');
}

int n,m,q;
namespace Decode{
	int R=0;
	int rotate(int element)
	{
	   element=(element+R)%n;

	   if (element==0) {
	       element=n;
	   }

	   return element;
	}
};

int info[maxn],Prev[maxn<<1],to[maxn<<1],cnt_e=1;
void Node(int u,int v){ Prev[++cnt_e]=info[u],info[u]=cnt_e,to[cnt_e]=v; }

int dfn[maxn],low[maxn],tot,sta[maxn],c[maxn],scc;
void dfs0(int u,int ff){//ff is an edge
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=info[u],v;i;i=Prev[i]) if(i^ff){
		v = to[i];
		if(!dfn[v]) dfs0(v,i^1),low[u]=min(low[u],low[v]);
		else low[u]=min(low[u],dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			t=sta[sta[0]--];
			c[t] = scc;
		}
	}
}

vector<int>G[maxn];
int sz[maxn],tp[maxn],fa[maxn],son[maxn],dep[maxn],X[maxn],A[maxn],B[maxn],st[maxn];
void dfs1(int u,int ff){
	dep[u] = dep[fa[u] = ff] + (sz[u] = 1);
	st[u] = ++tot;
	for(int v:G[u])
		if(v!=ff)
			dfs1(v,u),sz[u]+=sz[v],(sz[son[u]]<sz[v]) && (son[u]=v);
}
void dfs2(int u,int ff){
	if(son[u]) tp[son[u]] = tp[u] , dfs2(son[u],u);
	for(int v:G[u]) if(v!=ff && v!= son[u])
		dfs2(tp[v]=v,u);
}
int Lca(int u,int v){
	for(;tp[u]^tp[v];u=fa[tp[u]])
		if(dep[tp[u]] < dep[tp[v]])
			swap(u,v);
	return dep[u] < dep[v] ? u : v;
}

int fir[maxn],nxt[maxn<<4],tar[maxn<<4],cnte=1;
void add(int u,int v){ nxt[++cnte] = fir[u] , fir[u] = cnte , tar[cnte] = v;}
bool cmp(const int &u,const int &v){ return st[u] < st[v]; }

int bl[maxn];
void dfs3(int u,int ff){
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=fir[u],v;i;i=nxt[i]) if(i ^ ff){
		v = tar[i];
		if(!dfn[v]) dfs3(v,i^1) , low[u] = min(low[u] , low[v]);
		else low[u] = min(low[u] , dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			bl[t=sta[sta[0]--]] = scc;
		}
	}
}

int main(){

//	freopen("1.in","r",stdin);

	read(n),read(m),read(q);
	rep(i,1,m){
		int u,v;read(u),read(v);
		Node(u,v),Node(v,u);
	}
	rep(i,1,n) if(!dfn[i]) dfs0(i,0);
	memset(dfn,0,sizeof dfn);
	memset(low,0,sizeof low);
	tot = 0;
	rep(i,1,n) for(int j=info[i],v;j;j=Prev[j])
		if(c[i] ^ c[to[j]])
			G[c[i]].push_back(c[to[j]]),
			G[c[to[j]]].push_back(c[i]);
	rep(i,1,scc) if(!fa[i])
		dfs1(i,0),dfs2(tp[i]=i,0);
	tot = scc = 0;
	for(int V,E;q--;){
		read(V),read(E);
		static int ar[maxn << 3]={} , pt[maxn] , st[maxn] , tp=0;
		rep(i,1,V) read(X[i]),X[i]=Decode::rotate(X[i]),ar[++ar[0]] = c[X[i]];
		rep(i,1,E){
			read(A[i]),read(B[i]);
			A[i]=Decode::rotate(A[i]);
			B[i]=Decode::rotate(B[i]);
			ar[++ar[0]] = c[A[i]] , ar[++ar[0]] = c[B[i]];
			add(c[A[i]],c[B[i]]),add(c[B[i]],c[A[i]]);
		}
		sort(ar+1,ar+1+ar[0],cmp);
		ar[0]=unique(ar+1,ar+1+ar[0])-ar-1;
		rep(i,1,ar[0]){
			if(tp){
				int t = Lca(st[tp] , ar[i]) , p = 0;
				if(!t){
					for(;tp;p=st[tp--])
						if(p)
							add(p,st[tp]),add(st[tp],p);
				}
				else{
					for(;tp && dep[st[tp]] > dep[t];p=st[tp--])
						if(p)
							add(st[tp],p),add(p,st[tp]);
					if(st[tp] ^ t) st[++tp] = pt[++pt[0]] = t;
					if(p) add(st[tp],p) , add(p,st[tp]);
				}
			}
			st[++tp] = pt[++pt[0]] = ar[i];
		}
		int rt=0;
		for(;tp;rt=st[tp--])
			if(rt)
				add(rt,st[tp]),add(st[tp],rt);
		rep(i,1,pt[0]) if(!dfn[pt[i]])
			dfs3(pt[i],0);
		int hp = bl[c[X[1]]];
		rep(i,1,V)
			if(bl[c[X[i]]] != hp){
				hp = -1;
				break;
			}
		static int T = 0;
		++T;
		if(hp == -1) puts("NO");
		else puts("YES") , (Decode::R+=T) %= n;
		rep(i,1,pt[0]) fir[pt[i]] = dfn[pt[i]] = low[pt[i]] = bl[pt[i]] = 0;
		ar[0] = pt[0] = tot = tp = scc = 0;
		cnte = 1;
	}
}


#include<bits/stdc++.h>
#define maxn 900005
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)
using namespace std;

char cb[1<<16],*cs=cb,*ct=cb;
#define getc() (cs==ct&&(ct=(cs=cb)+fread(cb,1,1<<16,stdin),cs==ct)?0:*cs++)
void read(int &res){
	char ch;
	for(;!isdigit(ch=getc()););
	for(res=ch-'0';isdigit(ch=getc());res=res*10+ch-'0');
}

int n,m,q;
namespace Decode{
	int R=0;
	int rotate(int element)
	{
	   element=(element+R)%n;

	   if (element==0) {
	       element=n;
	   }

	   return element;
	}
};

int info[maxn],Prev[maxn<<1],to[maxn<<1],cnt_e=1;
void Node(int u,int v){ Prev[++cnt_e]=info[u],info[u]=cnt_e,to[cnt_e]=v; }

int dfn[maxn],low[maxn],tot,sta[maxn],c[maxn],scc;
void dfs0(int u,int ff){//ff is an edge
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=info[u],v;i;i=Prev[i]) if(i^ff){
		v = to[i];
		if(!dfn[v]) dfs0(v,i^1),low[u]=min(low[u],low[v]);
		else low[u]=min(low[u],dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			t=sta[sta[0]--];
			c[t] = scc;
		}
	}
}

vector<int>G[maxn];
int sz[maxn],tp[maxn],fa[maxn],son[maxn],dep[maxn],X[maxn],A[maxn],B[maxn],st[maxn];
void dfs1(int u,int ff){
	dep[u] = dep[fa[u] = ff] + (sz[u] = 1);
	st[u] = ++tot;
	for(int v:G[u])
		if(v!=ff)
			dfs1(v,u),sz[u]+=sz[v],(sz[son[u]]<sz[v]) && (son[u]=v);
}
void dfs2(int u,int ff){
	if(son[u]) tp[son[u]] = tp[u] , dfs2(son[u],u);
	for(int v:G[u]) if(v!=ff && v!= son[u])
		dfs2(tp[v]=v,u);
}
int Lca(int u,int v){
	for(;tp[u]^tp[v];u=fa[tp[u]])
		if(dep[tp[u]] < dep[tp[v]])
			swap(u,v);
	return dep[u] < dep[v] ? u : v;
}

int fir[maxn],nxt[maxn<<4],tar[maxn<<4],cnte=1;
void add(int u,int v){ nxt[++cnte] = fir[u] , fir[u] = cnte , tar[cnte] = v;}
bool cmp(const int &u,const int &v){ return st[u] < st[v]; }

int bl[maxn];
void dfs3(int u,int ff){
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=fir[u],v;i;i=nxt[i]) if(i ^ ff){
		v = tar[i];
		if(!dfn[v]) dfs3(v,i^1) , low[u] = min(low[u] , low[v]);
		else low[u] = min(low[u] , dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			bl[t=sta[sta[0]--]] = scc;
		}
	}
}

int main(){
	read(n),read(m),read(q);
	rep(i,1,m){
		int u,v;read(u),read(v);
		Node(u,v),Node(v,u);
	}
	rep(i,1,n) if(!dfn[i]) dfs0(i,0);
	memset(dfn,0,sizeof dfn);
	memset(low,0,sizeof low);
	tot = 0;
	rep(i,1,n) for(int j=info[i],v;j;j=Prev[j])
		if(c[i] ^ c[to[j]])
			G[c[i]].push_back(c[to[j]]),
			G[c[to[j]]].push_back(c[i]);
	rep(i,1,scc) if(!fa[i])
		dfs1(i,0),dfs2(tp[i]=i,0);
	tot = scc = 0;
	for(int V,E;q--;){
		read(V),read(E);
		static int ar[maxn << 3]={} , pt[maxn] , st[maxn] , tp=0;
		rep(i,1,V) read(X[i]),X[i]=Decode::rotate(X[i]),ar[++ar[0]] = c[X[i]];
		rep(i,1,E){
			read(A[i]),read(B[i]);
			A[i]=Decode::rotate(A[i]);
			B[i]=Decode::rotate(B[i]);
			if(c[A[i]] ^ c[B[i]])
				ar[++ar[0]] = c[A[i]] , ar[++ar[0]] = c[B[i]],
				add(c[A[i]],c[B[i]]),add(c[B[i]],c[A[i]]);
		}
		sort(ar+1,ar+1+ar[0],cmp);
		ar[0]=unique(ar+1,ar+1+ar[0])-ar-1;
		rep(i,1,ar[0]){
			if(tp){
				int t = Lca(st[tp] , ar[i]) , p = 0;
				if(!t){
					for(;tp;p=st[tp--])
						if(p)
							add(p,st[tp]),add(st[tp],p);
				}
				else{
					for(;tp && dep[st[tp]] > dep[t];p=st[tp--])
						if(p)
							add(st[tp],p),add(p,st[tp]);
					if(st[tp] ^ t) st[++tp] = pt[++pt[0]] = t;
					if(p) add(st[tp],p) , add(p,st[tp]);
				}
			}
			st[++tp] = pt[++pt[0]] = ar[i];
		}
		int rt=0;
		for(;tp;rt=st[tp--])
			if(rt)
				add(rt,st[tp]),add(st[tp],rt);
		rep(i,1,pt[0]) if(!dfn[pt[i]])
			dfs3(pt[i],0);
		int hp = bl[c[X[1]]];
		rep(i,1,V)
			if(bl[c[X[i]]] != hp){
				hp = -1;
				break;
			}
		static int T = 0;
		++T;
		if(hp == -1) puts("NO");
		else puts("YES") , (Decode::R+=T) %= n;
		rep(i,1,pt[0]) fir[pt[i]] = dfn[pt[i]] = low[pt[i]] = bl[pt[i]] = 0;
		ar[0] = pt[0] = tot = tp = scc = 0;
		cnte = 1;
	}
}


#include<bits/stdc++.h>
#define maxn 300005
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)
using namespace std;

char cb[1<<16],*cs=cb,*ct=cb;
#define getc() (cs==ct&&(ct=(cs=cb)+fread(cb,1,1<<16,stdin),cs==ct)?0:*cs++)
void read(int &res){
	char ch;
	for(;!isdigit(ch=getc()););
	for(res=ch-'0';isdigit(ch=getc());res=res*10+ch-'0');
}

int n,m,q;
namespace Decode{
	int R;
	int rotate(int element)
	{
	   element=(element+R)%n;

	   if (element==0) {
	       element=n;
	   }

	   return element;
	}
};

int info[maxn],Prev[maxn<<1],to[maxn<<1],cnt_e=1;
void Node(int u,int v){ Prev[++cnt_e]=info[u],info[u]=cnt_e,to[cnt_e]=v; }

int dfn[maxn],low[maxn],tot,sta[maxn],c[maxn],scc;
void dfs0(int u,int ff){//ff is an edge
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=info[u],v;i;i=Prev[i]) if(i^ff){
		v = to[i];
		if(!dfn[v]) dfs0(v,i^1),low[u]=min(low[u],low[v]);
		else low[u]=min(low[u],dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			t=sta[sta[0]--];
			c[t] = scc;
		}
	}
}

vector<int>G[maxn];
int sz[maxn],tp[maxn],fa[maxn],son[maxn],dep[maxn],X[maxn],A[maxn],B[maxn],st[maxn];
void dfs1(int u,int ff){
	dep[u] = dep[fa[u] = ff] + (sz[u] = 1);
	st[u] = ++tot;
	for(int v:G[u])
		if(v!=ff)
			dfs1(v,u),sz[u]+=sz[v],(sz[son[u]]<sz[v]) && (son[u]=v);
}
void dfs2(int u,int ff){
	if(son[u]) tp[son[u]] = tp[u] , dfs2(son[u],u);
	for(int v:G[u]) if(v!=ff && v!= son[u])
		dfs2(tp[v]=v,u);
}
int Lca(int u,int v){
	for(;tp[u]^tp[v];u=fa[tp[u]])
		if(dep[tp[u]] < dep[tp[v]])
			swap(u,v);
	return dep[u] < dep[v] ? u : v;
}

int fir[maxn],nxt[maxn<<1],tar[maxn<<1],cnte=1;
void add(int u,int v){ nxt[++cnte] = fir[u] , fir[u] = cnte , tar[cnte] = v;}
bool cmp(const int &u,const int &v){ return st[u] < st[v]; }

int bl[maxn];
void dfs3(int u,int ff){
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=fir[u],v;i;i=nxt[i]) if(i ^ ff){
		v = tar[i];
		if(!dfn[v]) dfs3(v,i^1) , low[u] = min(low[u] , low[v]);
		else low[u] = min(low[u] , dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			bl[t=sta[sta[0]--]] = scc;
		}
	}
}

int main(){

//	freopen("1.in","r",stdin);

	read(n),read(m),read(q);
	rep(i,1,m){
		int u,v;read(u),read(v);
		Node(u,v),Node(v,u);
	}
	rep(i,1,n) if(!dfn[i]) dfs0(i,0);
	memset(dfn,0,sizeof dfn);
	memset(low,0,sizeof low);
	tot = 0;
	rep(i,1,n) for(int j=info[i],v;j;j=Prev[j])
		if(c[i] ^ c[to[j]])
			G[c[i]].push_back(c[to[j]]),
			G[c[to[j]]].push_back(c[i]);
	dfs1(1,0),dfs2(tp[1]=1,0);
//	rep(i,1,n) printf("%d\n",c[i]);
	tot = scc = 0;
	for(int V,E;q--;){
		read(V),read(E);
		static int ar[maxn << 3]={} , pt[maxn] , st[maxn] , tp=0;
		rep(i,1,V) read(X[i]),X[i]=Decode::rotate(X[i]),ar[++ar[0]] = c[X[i]];
		rep(i,1,E){
			read(A[i]),read(B[i]);
			A[i]=Decode::rotate(A[i]);
			B[i]=Decode::rotate(B[i]);
			ar[++ar[0]] = c[A[i]] , ar[++ar[0]] = c[B[i]];
			add(c[A[i]],c[B[i]]),add(c[B[i]],c[A[i]]);
		}
		sort(ar+1,ar+1+ar[0],cmp);
		ar[0]=unique(ar+1,ar+1+ar[0])-ar-1;
		rep(i,1,ar[0]){
			if(tp){
				int t = Lca(st[tp] , ar[i]) , p = 0;
				for(;tp && dep[st[tp]] > dep[t];p=st[tp--])
					if(p)
						add(st[tp],p),add(p,st[tp]);
				if(st[tp] ^ t) st[++tp] = pt[++pt[0]] = t;
				if(p) add(st[tp],p) , add(p,st[tp]);
			}
			st[++tp] = pt[++pt[0]] = ar[i];
		}
		int rt=0;
		for(;tp;rt=st[tp--])
			if(rt)
				add(rt,st[tp]),add(st[tp],rt);
		rep(i,1,pt[0]) if(!dfn[pt[i]])
			dfs3(pt[i],0);
		set<int>hp;
		rep(i,1,V)
			hp.insert(bl[c[X[i]]]);
		if(hp.size() > 1) puts("NO");
		else puts("YES") , Decode::R++;
		rep(i,1,pt[0]) fir[pt[i]] = dfn[pt[i]] = low[pt[i]] = bl[pt[i]] = 0;
		ar[0] = pt[0] = tot = tp = scc = 0;
		cnte = 1;
	}
}


#include<bits/stdc++.h>
#define maxn 900005
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)
using namespace std;

char cb[1<<16],*cs=cb,*ct=cb;
#define getc() (cs==ct&&(ct=(cs=cb)+fread(cb,1,1<<16,stdin),cs==ct)?0:*cs++)
void read(int &res){
	char ch;
	for(;!isdigit(ch=getc()););
	for(res=ch-'0';isdigit(ch=getc());res=res*10+ch-'0');
}

int n,m,q;
namespace Decode{
	int R=0;
	int rotate(int element)
	{
	   element=(element+R)%n;

	   if (element==0) {
	       element=n;
	   }

	   return element;
	}
};

int info[maxn],Prev[maxn<<1],to[maxn<<1],cnt_e=1;
void Node(int u,int v){ Prev[++cnt_e]=info[u],info[u]=cnt_e,to[cnt_e]=v; }

int dfn[maxn],low[maxn],tot,sta[maxn],c[maxn],scc;
void dfs0(int u,int ff){//ff is an edge
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=info[u],v;i;i=Prev[i]) if(i^ff){
		v = to[i];
		if(!dfn[v]) dfs0(v,i^1),low[u]=min(low[u],low[v]);
		else low[u]=min(low[u],dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			t=sta[sta[0]--];
			c[t] = scc;
		}
	}
}

vector<int>G[maxn];
int sz[maxn],tp[maxn],fa[maxn],son[maxn],dep[maxn],X[maxn],A[maxn],B[maxn],st[maxn];
void dfs1(int u,int ff){
	dep[u] = dep[fa[u] = ff] + (sz[u] = 1);
	st[u] = ++tot;
	for(int v:G[u])
		if(v!=ff)
			dfs1(v,u),sz[u]+=sz[v],(sz[son[u]]<sz[v]) && (son[u]=v);
}
void dfs2(int u,int ff){
	if(son[u]) tp[son[u]] = tp[u] , dfs2(son[u],u);
	for(int v:G[u]) if(v!=ff && v!= son[u])
		dfs2(tp[v]=v,u);
}
int Lca(int u,int v){
	for(;tp[u]^tp[v];u=fa[tp[u]])
		if(dep[tp[u]] < dep[tp[v]])
			swap(u,v);
	return dep[u] < dep[v] ? u : v;
}

int fir[maxn],nxt[maxn<<4],tar[maxn<<4],cnte=1;
void add(int u,int v){ nxt[++cnte] = fir[u] , fir[u] = cnte , tar[cnte] = v;}
bool cmp(const int &u,const int &v){ return st[u] < st[v]; }

int bl[maxn];
void dfs3(int u,int ff){
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=fir[u],v;i;i=nxt[i]) if(i ^ ff){
		v = tar[i];
		if(!dfn[v]) dfs3(v,i^1) , low[u] = min(low[u] , low[v]);
		else low[u] = min(low[u] , dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			bl[t=sta[sta[0]--]] = scc;
		}
	}
}

int main(){
	read(n),read(m),read(q);
	rep(i,1,m){
		int u,v;read(u),read(v);
		Node(u,v),Node(v,u);
	}
	rep(i,1,n) if(!dfn[i]) dfs0(i,0);
	memset(dfn,0,sizeof dfn);
	memset(low,0,sizeof low);
	tot = 0;
	rep(i,1,n) for(int j=info[i],v;j;j=Prev[j])
		if(c[i] ^ c[to[j]])
			G[c[i]].push_back(c[to[j]]),
			G[c[to[j]]].push_back(c[i]);
	rep(i,1,scc) if(!fa[i])
		dfs1(i,0),dfs2(tp[i]=i,0);
	tot = scc = 0;
	for(int V,E;q--;){
		read(V),read(E);
		static int ar[maxn << 3]={} , pt[maxn] , st[maxn] , tp=0;
		rep(i,1,V) read(X[i]),X[i]=Decode::rotate(X[i]),ar[++ar[0]] = c[X[i]];
		rep(i,1,E){
			read(A[i]),read(B[i]);
			A[i]=Decode::rotate(A[i]);
			B[i]=Decode::rotate(B[i]);
			ar[++ar[0]] = c[A[i]] , ar[++ar[0]] = c[B[i]];
			add(c[A[i]],c[B[i]]),add(c[B[i]],c[A[i]]);
		}
		sort(ar+1,ar+1+ar[0],cmp);
		ar[0]=unique(ar+1,ar+1+ar[0])-ar-1;
		rep(i,1,ar[0]){
			if(tp){
				int t = Lca(st[tp] , ar[i]) , p = 0;
				if(!t){
					for(;tp;p=st[tp--])
						if(p)
							add(p,st[tp]),add(st[tp],p);
				}
				else{
					for(;tp && dep[st[tp]] > dep[t];p=st[tp--])
						if(p)
							add(st[tp],p),add(p,st[tp]);
					if(st[tp] ^ t) st[++tp] = pt[++pt[0]] = t;
					if(p) add(st[tp],p) , add(p,st[tp]);
				}
			}
			st[++tp] = pt[++pt[0]] = ar[i];
		}
		int rt=0;
		for(;tp;rt=st[tp--])
			if(rt)
				add(rt,st[tp]),add(st[tp],rt);
		rep(i,1,pt[0]) if(!dfn[pt[i]])
			dfs3(pt[i],0);
		int hp = bl[c[X[1]]];
		rep(i,1,V)
			if(bl[c[X[i]]] != hp){
				hp = -1;
				break;
			}
		static int T = 0;
		++T;
		if(hp == -1) puts("NO");
		else puts("YES") , (Decode::R+=T) %= n;
		rep(i,1,pt[0]) fir[pt[i]] = dfn[pt[i]] = low[pt[i]] = bl[pt[i]] = 0;
		ar[0] = pt[0] = tot = tp = scc = 0;
		cnte = 1;
	}
}


#include<bits/stdc++.h>
#define maxn 300005
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)
using namespace std;

char cb[1<<16],*cs=cb,*ct=cb;
#define getc() (cs==ct&&(ct=(cs=cb)+fread(cb,1,1<<16,stdin),cs==ct)?0:*cs++)
void read(int &res){
	char ch;
	for(;!isdigit(ch=getc()););
	for(res=ch-'0';isdigit(ch=getc());res=res*10+ch-'0');
}

int n,m,q;
namespace Decode{
	int R=0;
	int rotate(int element)
	{
	   element=(element+R)%n;

	   if (element==0) {
	       element=n;
	   }

	   return element;
	}
};

int info[maxn],Prev[maxn<<1],to[maxn<<1],cnt_e=1;
void Node(int u,int v){ Prev[++cnt_e]=info[u],info[u]=cnt_e,to[cnt_e]=v; }

int dfn[maxn],low[maxn],tot,sta[maxn],c[maxn],scc;
void dfs0(int u,int ff){//ff is an edge
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=info[u],v;i;i=Prev[i]) if(i^ff){
		v = to[i];
		if(!dfn[v]) dfs0(v,i^1),low[u]=min(low[u],low[v]);
		else low[u]=min(low[u],dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			t=sta[sta[0]--];
			c[t] = scc;
		}
	}
}

vector<int>G[maxn];
int sz[maxn],tp[maxn],fa[maxn],son[maxn],dep[maxn],X[maxn],A[maxn],B[maxn],st[maxn];
void dfs1(int u,int ff){
	dep[u] = dep[fa[u] = ff] + (sz[u] = 1);
	st[u] = ++tot;
	for(int v:G[u])
		if(v!=ff)
			dfs1(v,u),sz[u]+=sz[v],(sz[son[u]]<sz[v]) && (son[u]=v);
}
void dfs2(int u,int ff){
	if(son[u]) tp[son[u]] = tp[u] , dfs2(son[u],u);
	for(int v:G[u]) if(v!=ff && v!= son[u])
		dfs2(tp[v]=v,u);
}
int Lca(int u,int v){
	for(;tp[u]^tp[v];u=fa[tp[u]])
		if(dep[tp[u]] < dep[tp[v]])
			swap(u,v);
	return dep[u] < dep[v] ? u : v;
}

int fir[maxn],nxt[maxn<<4],tar[maxn<<4],cnte=1;
void add(int u,int v){ nxt[++cnte] = fir[u] , fir[u] = cnte , tar[cnte] = v;}
bool cmp(const int &u,const int &v){ return st[u] < st[v]; }

int bl[maxn];
void dfs3(int u,int ff){
	dfn[u] = low[u] = ++tot;
	sta[++sta[0]] = u;
	for(int i=fir[u],v;i;i=nxt[i]) if(i ^ ff){
		v = tar[i];
		if(!dfn[v]) dfs3(v,i^1) , low[u] = min(low[u] , low[v]);
		else low[u] = min(low[u] , dfn[v]);
	}
	if(low[u] == dfn[u]){
		scc++;
		for(int t=-1;t!=u;){
			bl[t=sta[sta[0]--]] = scc;
		}
	}
}

int main(){

//	freopen("1.in","r",stdin);

	read(n),read(m),read(q);
	rep(i,1,m){
		int u,v;read(u),read(v);
		Node(u,v),Node(v,u);
	}
	rep(i,1,n) if(!dfn[i]) dfs0(i,0);
	memset(dfn,0,sizeof dfn);
	memset(low,0,sizeof low);
	tot = 0;
	rep(i,1,n) for(int j=info[i],v;j;j=Prev[j])
		if(c[i] ^ c[to[j]])
			G[c[i]].push_back(c[to[j]]),
			G[c[to[j]]].push_back(c[i]);
	rep(i,1,scc) if(!fa[i])
		dfs1(i,0),dfs2(tp[i]=i,0);
	tot = scc = 0;
	for(int V,E;q--;){
		read(V),read(E);
		static int ar[maxn << 3]={} , pt[maxn] , st[maxn] , tp=0;
		rep(i,1,V) read(X[i]),X[i]=Decode::rotate(X[i]),ar[++ar[0]] = c[X[i]];
		rep(i,1,E){
			read(A[i]),read(B[i]);
			A[i]=Decode::rotate(A[i]);
			B[i]=Decode::rotate(B[i]);
			ar[++ar[0]] = c[A[i]] , ar[++ar[0]] = c[B[i]];
			add(c[A[i]],c[B[i]]),add(c[B[i]],c[A[i]]);
		}
		sort(ar+1,ar+1+ar[0],cmp);
		ar[0]=unique(ar+1,ar+1+ar[0])-ar-1;
		rep(i,1,ar[0]){
			if(tp){
				int t = Lca(st[tp] , ar[i]) , p = 0;
				if(!t){
					for(;tp;p=st[tp--])
						if(p)
							add(p,st[tp]),add(st[tp],p);
				}
				else{
					for(;tp && dep[st[tp]] > dep[t];p=st[tp--])
						if(p)
							add(st[tp],p),add(p,st[tp]);
					if(st[tp] ^ t) st[++tp] = pt[++pt[0]] = t;
					if(p) add(st[tp],p) , add(p,st[tp]);
				}
			}
			st[++tp] = pt[++pt[0]] = ar[i];
		}
		int rt=0;
		for(;tp;rt=st[tp--])
			if(rt)
				add(rt,st[tp]),add(st[tp],rt);
		rep(i,1,pt[0]) if(!dfn[pt[i]])
			dfs3(pt[i],0);
		set<int>hp;
		rep(i,1,V)
			hp.insert(bl[c[X[i]]]);
		static int T = 0;
		++T;
		if(hp.size() > 1) puts("NO");
		else puts("YES") , (Decode::R+=T) %= n;
		rep(i,1,pt[0]) fir[pt[i]] = dfn[pt[i]] = low[pt[i]] = bl[pt[i]] = 0;
		ar[0] = pt[0] = tot = tp = scc = 0;
		cnte = 1;
	}
}


#include<bits/stdc++.h>
#define pb(a) push_back(a)
using namespace std;
inline void read(int &x)
{
	x=0;char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+c-48,c=getchar();
}
const int maxn=1e6+5;
int n,m,q,ct,dfn[maxn],bl[maxn],is[maxn];
vector<int> F,R;
int find(int x) {return is[x]==x?x:is[x]=find(is[x]);}
struct Graph{
	int tot=1,first[maxn];
	struct Road{int u,t,nxt;}e[maxn];
	void add(int x,int y) {e[++tot]=(Road){x,y,first[x]};first[x]=tot;}
	void link(int x,int y) {add(x,y);add(y,x);}
	void clear() {for(int i=2;i<=tot;++i) first[e[i].u]=first[e[i].t]=0;tot=1;}
}G,T,H;
struct Tarjan{
	int rg,n,ct,dex,low[maxn],dfn[maxn],bl[maxn],bri[maxn],fat[maxn];
	int find(int x) {return x==fat[x]?x:fat[x]=find(fat[x]);}
	void tarjan(int x,int f,Graph &G)
	{
		dfn[x]=low[x]=++dex;
		for(int i=G.first[x],t;i;i=G.e[i].nxt)
			if(i^f^1)
			{
				t=G.e[i].t;
				if(!dfn[t]) tarjan(t,i,G),low[x]=min(low[t],low[x]),bri[i]=bri[i^1]=low[t]>dfn[x];
				else low[x]=min(low[x],dfn[t]);
			}
	}
	void getbl(vector<int> t,Graph &G)
	{
		for(int i=0;i<t.size();++i) fat[t[i]]=t[i];
		for(int i=2;i<=G.tot;i+=2) if(!bri[i]) fat[find(G.e[i].u)]=find(G.e[i].t);
		for(int i=0;i<t.size();++i) bl[t[i]]=find(t[i]);
	}
	void init(vector<int> t,Graph &G)
	{
		n=t.size()-1;
		for(int i=0;i<=n;++i) if(!dfn[t[i]]) tarjan(t[i],0,G);
	}
	void clear(vector<int> t,Graph &G)
	{
		n=ct=dex=rg=0;
		for(int i=0;i<t.size();++i) dfn[t[i]]=low[t[i]]=bl[t[i]]=fat[t[i]]=0;
		for(int i=0;i<=G.tot;++i) bri[i]=0;
	}
	int jud(vector<int> t)
	{
		int g=bl[t[0]];
		for(int i=1;i<t.size();++i) if(g!=bl[t[i]]) return 0;
		return 1;
	}
}tj;
int cmp(int a,int b) {return dfn[a]<dfn[b];}
struct Fake_Tree{
	int dex,ct,tp,st[maxn],le[maxn],dep[maxn];
	int p,bin[20],len[maxn],f[maxn][20];
	void frdfs(int x,int fa)
	{
		dep[x]=dep[fa]+1;dfn[x]=++dex;f[le[x]=++ct][0]=x;
		for(int i=T.first[x],t;i;i=T.e[i].nxt)
			if(T.e[i].t!=fa)
				frdfs(T.e[i].t,x),f[++ct][0]=x;
	}
	void init()
	{
		p=log(ct)/log(2)+1;
		for(int i=bin[0]=1;i<=p;++i) bin[i]=bin[i-1]<<1;
		for(int i=1;i<=ct;++i) len[i]=log(i)/log(2);
		for(int j=1;j<=p;++j)
			for(int i=1;i+bin[j]-1<=ct;++i)
				if(dep[f[i][j-1]]<dep[f[i+bin[j-1]][j-1]]) f[i][j]=f[i][j-1];
				else f[i][j]=f[i+bin[j-1]][j-1];
	}
	int LCA(int x,int y)
	{
		if(le[x]>le[y]) swap(x,y);
		int l=len[le[y]-le[x]+1];
		if(dep[f[le[x]][l]]<dep[f[le[y]-bin[l]+1][l]]) return f[le[x]][l];
		else return f[le[y]-bin[l]+1][l];
	}
	void preit(vector<int> t) {for(int i=0;i<t.size();++i) if(!dfn[t[i]]) frdfs(t[i],0);init();}
	void ins(int x)
	{
		if(!tp) return st[++tp]=x,void();
		int lca=LCA(x,st[tp]);
		if(st[tp]==lca) return st[++tp]=x,void();
		F.pb(lca);
		while(tp>1&&dfn[lca]<=dfn[st[tp-1]]) H.link(st[tp-1],st[tp]),--tp;
		if(st[tp]^lca) H.link(lca,st[tp]),st[tp]=lca;
		st[++tp]=x;
	}
	void fktree(vector<int> t)
	{
		sort(t.begin(),t.end(),cmp);ins(t[0]);
		for(int i=1;i<t.size();++i)
		{
			if(is[t[i]]==is[t[i-1]]) ins(t[i]);
			else {while(tp>1) H.link(st[tp-1],st[tp]),--tp;tp=0;ins(t[i]);}
		}
		while(tp>1) H.link(st[tp-1],st[tp]),--tp;tp=0;
	}
}fkt;
int main()
{
	read(n),read(m),read(q);
	for(int i=1;i<=n;++i) is[i]=i;
	for(int i=1,x,y;i<=m;++i) read(x),read(y),G.link(x,y),is[find(x)]=find(y);
	for(int i=1;i<=n;++i) is[i]=find(i),F.pb(i);
	tj.init(F,G);tj.getbl(F,G);
	for(int i=1;i<=n;++i) bl[i]=tj.bl[i];
	tj.clear(F,G);
	for(int i=2;i<=G.tot;i+=2) if(bl[G.e[i].u]!=bl[G.e[i].t]) T.link(bl[G.e[i].u],bl[G.e[i].t]);
	F.clear();
	for(int i=1;i<=n;++i) if(bl[i]==i) F.pb(i);
	fkt.preit(F);
	for(int i=1,V,E;i<=q;++i)
	{
		read(V),read(E);F.resize(V);H.clear();R.clear();
		for(int i=0;i<V;++i) read(F[i]),F[i]=bl[F[i]];R=F;
		for(int i=1,x,y;i<=E;++i)
		{
			read(x),read(y);
			if(bl[x]!=bl[y]) H.link(bl[x],bl[y]),F.pb(bl[x]),F.pb(bl[y]);
		}
		sort(F.begin(),F.end());F.resize(unique(F.begin(),F.end())-F.begin());
		sort(R.begin(),R.end());R.resize(unique(R.begin(),R.end())-R.begin());
		fkt.fktree(F);tj.init(F,H);tj.getbl(F,H);
		puts(!tj.jud(R)?"NO":"YES");
		tj.clear(F,H);
	}
	return 0;
}
/*
6 5 4
1 2
2 3
3 4
2 4
5 6

2 0
4 2

2 1
6 2
3 4

3 2
6 3 4
2 5
4 6

2 1
1 2
1 2

7 6 2
1 2
1 3
2 4
2 5
3 6
3 7

7 2
1 2 3 4 5 6 7
4 5
6 7

7 2
1 2 3 4 5 6 7
4 6
5 7

*/


#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#define maxn 500000
#define maxm 500000
#define maxlogn 25
using namespace std;

inline void qread(int &x) {
	x=0;
	int sign=1;
	char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-') sign=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	x=x*sign;
}
inline void qprint(long long x) {
	if(x<0) {
		putchar('-');
		qprint(-x);
	} else if(x==0) {
		putchar('0');
		return;
	} else {
		if(x/10>0) qprint(x/10);
		putchar('0'+x%10);
	}
}

int n,m,q;

struct graph {
	struct edge {
		int from;
		int to;
		int next;
	} E[maxm*2+5];
	int nodes[maxn+5];
	int head[maxn+5];
	int esz;
	int vsz;
	void add_node(int x) {
		vsz++;
		nodes[vsz]=x;
	}
	void unique_node() {
		sort(nodes+1,nodes+1+vsz);
		vsz=unique(nodes+1,nodes+1+vsz)-nodes-1;
	}
	void add_edge(int u,int v) {
		esz++;
		E[esz].from=u;
		E[esz].to=v;
		E[esz].next=head[u];
		head[u]=esz;
	}
	graph() {
		esz=1;
	}
	void clear() { //使用后清空
		esz=1;
		for(int i=1; i<=vsz; i++) head[nodes[i]]=0;
		vsz=0;
	}
	void debug() {
		printf("node=%d edge=%d\n",vsz,esz);
		for(int i=2; i<=esz; i+=2) {
			printf("debug:%d %d\n",E[i].from,E[i].to);
		}
	}
} G1,G2,G3;

namespace e_dcc {//边-双联通分量相关
	int tim,cnt;
	int dfn[maxn+5];
	int low[maxn+5];
	bool bridge[maxm*2+5];
	int bel[maxn+5];//存储属于第几个e-dcc
	bool vis[maxn+5];

	void tarjan(int x,int last,graph& G) {
		dfn[x]=++tim;
		low[x]=dfn[x];
		for(int i=G.head[x]; i; i=G.E[i].next) {
			int y=G.E[i].to;
			if(!dfn[y]) {
				tarjan(y,i,G);
				low[x]=min(low[x],low[y]);
				if(dfn[x]<low[y]) {
					bridge[i]=bridge[i^1]=1;
				}
			} else if(i!=(last^1)) low[x]=min(low[x],dfn[y]);
		}
	}

	void dfs_mark(int x,int col,graph& G) {
		bel[x]=col;
		vis[x]=1;
		for(int i=G.head[x]; i; i=G.E[i].next) {
			int y=G.E[i].to;
			if(!vis[y]&&!bridge[i]) {
				dfs_mark(y,col,G);
			}
		}
	}

	int get_bel(graph &G) {//求出v-dcc,不缩点,返回v-dcc数量
		for(int i=1; i<=G.vsz; i++) {
			int u=G.nodes[i];
			low[u]=dfn[u]=bel[u]=vis[u]=0;
		}
		for(int i=1; i<=G.esz; i++) bridge[i]=0;
		tim=0;
		for(int i=1; i<=G.vsz; i++) {
			if(!dfn[G.nodes[i]]) {
				tarjan(G.nodes[i],0,G);
			}
		}

		cnt=0;
		for(int i=1; i<=G.vsz; i++) {
			if(!vis[G.nodes[i]]) {
				cnt++;
				dfs_mark(G.nodes[i],cnt,G);
			}
		}
		return cnt;
	}

	void graph_to_tree(graph &in,graph &out) {//缩点
		get_bel(in);
		for(int i=2; i<=in.esz; i++) {
			if(bel[in.E[i].from]!=bel[in.E[i].to]) {
				out.add_edge(bel[in.E[i].from],bel[in.E[i].to]);
			}
		}
		out.vsz=cnt;
	}
}

vector<int>nodes;//虚树上的点
namespace virtual_tree {//虚树相关
	int log2n;
	int tim=0;
	int dfn[maxn+5];
	int deep[maxn+5];
	int rt[maxn+5];
	int anc[maxn+5][maxlogn+5];
	void dfs(int x,int fa,int root,graph &T1) {
		dfn[x]=++tim;
		rt[x]=root;
		deep[x]=deep[fa]+1;
		anc[x][0]=fa;
		for(int i=1; i<=log2n; i++)anc[x][i]=anc[anc[x][i-1]][i-1];
		for(int i=T1.head[x]; i; i=T1.E[i].next) {
			int y=T1.E[i].to;
			if(y!=fa) {
				dfs(y,x,root,T1);
			}
		}
	}
	int lca(int x,int y) {
		if(deep[x]<deep[y]) swap(x,y);
		for(int i=log2n; i>=0; i--) {
			if(deep[anc[x][i]]>=deep[y]) {
				x=anc[x][i];
			}
		}
		if(x==y) return x;
		for(int i=log2n; i>=0; i--) {
			if(anc[x][i]!=anc[y][i]) {
				x=anc[x][i];
				y=anc[y][i];
			}
		}
		return anc[x][0];
	}

	int top=0;
	int s[maxn];
	int in[maxn];
	int cmp(int x,int y) {
		return dfn[x]<dfn[y];
	}

	void insert(int x,graph &T2) {
		if(top<1) {
			s[++top]=x;
			return;
		}
		int lc=lca(x,s[top]);
		if(lc==s[top]) {
			s[++top]=x;
			return;
		}
		while(top>1&&deep[s[top-1]]>=deep[lc]) {
			T2.add_edge(s[top-1],s[top]);
			T2.add_edge(s[top],s[top-1]);
			T2.add_node(s[top]);
			T2.add_node(s[top-1]);
			top--;
		}
		if(s[top]!=lc) {
			T2.add_edge(lc,s[top]);
			T2.add_edge(s[top],lc);
			T2.add_node(lc);
			T2.add_node(s[top]);
		}
		s[top]=lc;
		s[++top]=x;
	}

	void ini_tree(graph &in) { //初始化原来的森林
		log2n=log2(in.vsz)+1;
		for(int i=1; i<=in.vsz; i++) {
			if(!deep[i]) dfs(i,0,i,in);
		}
	}

	void get_vir_tree(int *in,int k,graph &out) { //对于每个询问,建出虚树
		sort(in+1,in+1+k,cmp);
		int r;
		for(int l=1; l<=k; l=r+1) {
			r=l;
			while(r<k&&rt[in[r]]==rt[in[r+1]]) r++;//找出在一棵树里的点
			top=0;
			for(int i=l; i<=r; i++) {
				insert(in[i],out);
			}
			while(top>1) {
				out.add_edge(s[top-1],s[top]);
				out.add_edge(s[top],s[top-1]);
				out.add_node(s[top-1]);
				out.add_node(s[top]);
				top--;
			}
			if(l==r) out.add_node(in[l]);
		}

	}
}

int org_bel[maxn+5];//点x在原图G1中的v-dcc编号,由于namespace里的不断在变，要保存一下

int org_point[maxn+5];
int point[maxn+5];
bool check(int tn){
	for(int i=2;i<=tn;i++){
		if(e_dcc::bel[org_point[i]]!=e_dcc::bel[org_point[1]]) return 0;
	}
	return 1;
}
int main() {
	int u,v;
	qread(n);
	qread(m);
	qread(q);
	for(int i=1; i<=n; i++) G1.add_node(i);
	for(int i=1; i<=m; i++) {
		qread(u);
		qread(v);
		G1.add_edge(u,v);
		G1.add_edge(v,u);
	}

	e_dcc::graph_to_tree(G1,G2);
//	G2.debug();
	for(int i=1; i<=n; i++) {
		org_bel[i]=e_dcc::bel[i];
//		else org_bel[i]=e_dcc::new_id[i];

	}
	virtual_tree::ini_tree(G2);

	int rcnt=0;
	int tn,tm,tsz;
	for(int i=1; i<=q; i++) {
		qread(tn);
		qread(tm);
		tsz=0;
		for(int j=1; j<=tn; j++) {
			qread(org_point[j]);
			org_point[j]=(org_point[j]+rcnt)%n;//强制在线
			if(org_point[j]==0) org_point[j]=n;
//			printf("db:%d\n",point[j]);
			org_point[j]=org_bel[org_point[j]];
			point[++tsz]=org_point[j];
		}

		for(int j=1; j<=tm; j++) {
			qread(u);
			qread(v);
			u=(u+rcnt)%n;
			if(u==0) u=n;
			v=(v+rcnt)%n;
			if(v==0) v=n;
//			printf("db %d %d\n",u,v);
			if(org_bel[v]!=org_bel[u]) {
				G3.add_edge(org_bel[u],org_bel[v]);
				G3.add_edge(org_bel[v],org_bel[u]);
				G3.add_node(org_bel[u]);
				G3.add_node(org_bel[v]);
			}
			point[++tsz]=org_bel[u];
			point[++tsz]=org_bel[v];//边上的点也要加进去建虚树
		}

		sort(point+1,point+1+tsz);
		tsz=unique(point+1,point+1+tsz)-point-1;
		virtual_tree::get_vir_tree(point,tsz,G3);
		G3.unique_node();
#ifdef DEBUG
		G3.debug();
#endif
		e_dcc::get_bel(G3);
		if(tn==1||check(tn)) {//不一定只有1个e-dcc，只要询问的tn个点在一个e-dcc中
			printf("YES\n");
			rcnt+=i;//是加上答案编号，不是+1
			rcnt%=n;
		} else {
			printf("NO\n");
		}

		G3.clear();//清空虚树
	}
}
/*
4 5 2
3 4
4 3
4 3
3 3
2 1

2 1
3 4
2 2

1 5
2
3 4
4 3
2 4
1 1
4 2

*/


#include<bits/stdc++.h>
#define pb(a) push_back(a)
using namespace std;
inline void read(int &x)
{
	x=0;char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+c-48,c=getchar();
}
const int maxn=1e6+5;
int n,m,q,ct,dfn[maxn],bl[maxn],is[maxn];
vector<int> F,R;
int find(int x) {return is[x]==x?x:is[x]=find(is[x]);}
struct Graph{
	int tot=1,first[maxn];
	struct Road{int u,t,nxt;}e[maxn];
	void add(int x,int y) {e[++tot]=(Road){x,y,first[x]};first[x]=tot;}
	void link(int x,int y) {add(x,y);add(y,x);}
	void clear() {for(int i=2;i<=tot;++i) first[e[i].u]=first[e[i].t]=0;tot=1;}
}G,T,H;
struct Tarjan{
	int rg,n,ct,dex,low[maxn],dfn[maxn],bl[maxn],bri[maxn],fat[maxn];
	int find(int x) {return x==fat[x]?x:fat[x]=find(fat[x]);}
	void tarjan(int x,int f,Graph &G)
	{
		dfn[x]=low[x]=++dex;
		for(int i=G.first[x],t;i;i=G.e[i].nxt)
			if(i^f^1)
			{
				t=G.e[i].t;
				if(!dfn[t]) tarjan(t,i,G),low[x]=min(low[t],low[x]),bri[i]=bri[i^1]=low[t]>dfn[x];
				else low[x]=min(low[x],dfn[t]);
			}
	}
	void getbl(vector<int> t,Graph &G)
	{
		for(int i=0;i<t.size();++i) fat[t[i]]=t[i];
		for(int i=2;i<=G.tot;i+=2) if(!bri[i]) fat[find(G.e[i].u)]=find(G.e[i].t);
		for(int i=0;i<t.size();++i) bl[t[i]]=find(t[i]);
	}
	void init(vector<int> t,Graph &G)
	{
		n=t.size()-1;
		for(int i=0;i<=n;++i) if(!dfn[t[i]]) tarjan(t[i],0,G);
	}
	void clear(vector<int> t,Graph &G)
	{
		n=ct=dex=rg=0;
		for(int i=0;i<t.size();++i) dfn[t[i]]=low[t[i]]=bl[t[i]]=fat[t[i]]=0;
		for(int i=0;i<=G.tot;++i) bri[i]=0;
	}
	int jud(vector<int> t)
	{
		int g=bl[t[0]];
		for(int i=1;i<t.size();++i) if(g!=bl[t[i]]) return 0;
		return 1;
	}
}tj;
int cmp(int a,int b) {return dfn[a]<dfn[b];}
struct Fake_Tree{
	int dex,ct,tp,st[maxn],le[maxn],dep[maxn];
	int p,bin[20],len[maxn],f[maxn][20];
	void frdfs(int x,int fa)
	{
		dep[x]=dep[fa]+1;dfn[x]=++dex;f[le[x]=++ct][0]=x;
		for(int i=T.first[x],t;i;i=T.e[i].nxt)
			if(T.e[i].t!=fa)
				frdfs(T.e[i].t,x),f[++ct][0]=x;
	}
	void init()
	{
		p=log(ct)/log(2)+1;
		for(int i=bin[0]=1;i<=p;++i) bin[i]=bin[i-1]<<1;
		for(int i=1;i<=ct;++i) len[i]=log(i)/log(2);
		for(int j=1;j<=p;++j)
			for(int i=1;i+bin[j]-1<=ct;++i)
				if(dep[f[i][j-1]]<dep[f[i+bin[j-1]][j-1]]) f[i][j]=f[i][j-1];
				else f[i][j]=f[i+bin[j-1]][j-1];
	}
	int LCA(int x,int y)
	{
		if(le[x]>le[y]) swap(x,y);
		int l=len[le[y]-le[x]+1];
		if(dep[f[le[x]][l]]<dep[f[le[y]-bin[l]+1][l]]) return f[le[x]][l];
		else return f[le[y]-bin[l]+1][l];
	}
	void preit(vector<int> t) {for(int i=0;i<t.size();++i) if(!dfn[t[i]]) frdfs(t[i],0);init();}
	void ins(int x)
	{
		if(!tp) return st[++tp]=x,void();
		int lca=LCA(x,st[tp]);
		if(st[tp]==lca) return st[++tp]=x,void();
		F.pb(lca);
		while(tp>1&&dfn[lca]<=dfn[st[tp-1]]) H.link(st[tp-1],st[tp]),--tp;
		if(st[tp]^lca) H.link(lca,st[tp]),st[tp]=lca;
		st[++tp]=x;
	}
	void fktree(vector<int> t)
	{
		sort(t.begin(),t.end(),cmp);ins(t[0]);
		for(int i=1;i<t.size();++i)
		{
			if(is[t[i]]==is[t[i-1]]) ins(t[i]);
			else {while(tp>1) H.link(st[tp-1],st[tp]),--tp;tp=0;ins(t[i]);}
		}
		while(tp>1) H.link(st[tp-1],st[tp]),--tp;tp=0;
	}
}fkt;
int main()
{
	read(n),read(m),read(q);
	for(int i=1;i<=n;++i) is[i]=i;
	for(int i=1,x,y;i<=m;++i) read(x),read(y),G.link(x,y),is[find(x)]=find(y);
	for(int i=1;i<=n;++i) is[i]=find(i),F.pb(i);
	tj.init(F,G);tj.getbl(F,G);
	for(int i=1;i<=n;++i) bl[i]=tj.bl[i];
	tj.clear(F,G);
	for(int i=2;i<=G.tot;i+=2) if(bl[G.e[i].u]!=bl[G.e[i].t]) T.link(bl[G.e[i].u],bl[G.e[i].t]);
	F.clear();
	for(int i=1;i<=n;++i) if(bl[i]==i) F.pb(i);
	fkt.preit(F);
	for(int i=1,V,E;i<=q;++i)
	{
		read(V),read(E);F.resize(V);H.clear();R.clear();
		for(int i=0;i<V;++i) read(F[i]),F[i]=bl[F[i]];R=F;
		for(int i=1,x,y;i<=E;++i)
		{
			read(x),read(y);
			if(bl[x]!=bl[y]) H.link(bl[x],bl[y]),F.pb(bl[x]),F.pb(bl[y]);
		}
		sort(F.begin(),F.end());F.resize(unique(F.begin(),F.end())-F.begin());
		sort(R.begin(),R.end());R.resize(unique(R.begin(),R.end())-R.begin());
		fkt.fktree(F);
		sort(F.begin(),F.end());F.resize(unique(F.begin(),F.end())-F.begin());
		tj.init(F,H);tj.getbl(F,H);
		puts(!tj.jud(R)?"NO":"YES");
		tj.clear(F,H);
	}
	return 0;
}
/*
6 5 4
1 2
2 3
3 4
2 4
5 6

2 0
4 2

2 1
6 2
3 4

3 2
6 3 4
2 5
4 6

2 1
1 2
1 2

7 6 2
1 2
1 3
2 4
2 5
3 6
3 7

7 2
1 2 3 4 5 6 7
4 5
6 7

7 2
1 2 3 4 5 6 7
4 6
5 7

*/


#include<bits/stdc++.h>
#define pb(a) push_back(a)
using namespace std;
inline void read(int &x)
{
	x=0;char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+c-48,c=getchar();
}
const int maxn=1e6+5;
int n,m,q,ct,dfn[maxn],bl[maxn],is[maxn];
vector<int> F,R,L;
int find(int x) {return is[x]==x?x:is[x]=find(is[x]);}
struct Graph{
	int tot=1,first[maxn];
	struct Road{int u,t,nxt;}e[maxn];
	void add(int x,int y) {e[++tot]=(Road){x,y,first[x]};first[x]=tot;}
	void link(int x,int y) {add(x,y);add(y,x);}
	void clear() {for(int i=2;i<=tot;++i) first[e[i].u]=first[e[i].t]=0;tot=1;}
}G,T,H;
struct Tarjan{
	int rg,n,ct,dex,low[maxn],dfn[maxn],bl[maxn],bri[maxn],fat[maxn];
	int find(int x) {return x==fat[x]?x:fat[x]=find(fat[x]);}
	void tarjan(int x,int f,Graph &G)
	{
		dfn[x]=low[x]=++dex;
		for(int i=G.first[x],t;i;i=G.e[i].nxt)
			if(i^f^1)
			{
				t=G.e[i].t;
				if(!dfn[t]) tarjan(t,i,G),low[x]=min(low[t],low[x]),bri[i]=bri[i^1]=low[t]>dfn[x];
				else low[x]=min(low[x],dfn[t]);
			}
	}
	void getbl(vector<int> t,Graph &G)
	{
		for(int i=0;i<t.size();++i) fat[t[i]]=t[i];
		for(int i=2;i<=G.tot;i+=2) if(!bri[i]) fat[find(G.e[i].u)]=find(G.e[i].t);
		for(int i=0;i<t.size();++i) bl[t[i]]=find(t[i]);
	}
	void init(vector<int> t,Graph &G)
	{
		n=t.size()-1;
		for(int i=0;i<=n;++i) if(!dfn[t[i]]) tarjan(t[i],0,G);
	}
	void clear(vector<int> t,Graph &G)
	{
		n=ct=dex=rg=0;
		for(int i=0;i<t.size();++i) dfn[t[i]]=low[t[i]]=bl[t[i]]=fat[t[i]]=0;
		for(int i=0;i<=G.tot;++i) bri[i]=0;
	}
	int jud(vector<int> t)
	{
		int g=bl[t[0]];
		for(int i=1;i<t.size();++i) if(g!=bl[t[i]]) return 0;
		return 1;
	}
}tj;
int cmp(int a,int b) {return dfn[a]<dfn[b];}
struct Fake_Tree{
	int dex,ct,tp,st[maxn],le[maxn],dep[maxn];
	int p,bin[20],len[maxn],f[maxn][20];
	void frdfs(int x,int fa)
	{
		dep[x]=dep[fa]+1;dfn[x]=++dex;f[le[x]=++ct][0]=x;
		for(int i=T.first[x],t;i;i=T.e[i].nxt)
			if(T.e[i].t!=fa)
				frdfs(T.e[i].t,x),f[++ct][0]=x;
	}
	void init()
	{
		p=log(ct)/log(2)+1;
		for(int i=bin[0]=1;i<=p;++i) bin[i]=bin[i-1]<<1;
		for(int i=1;i<=ct;++i) len[i]=log(i)/log(2);
		for(int j=1;j<=p;++j)
			for(int i=1;i+bin[j]-1<=ct;++i)
				if(dep[f[i][j-1]]<dep[f[i+bin[j-1]][j-1]]) f[i][j]=f[i][j-1];
				else f[i][j]=f[i+bin[j-1]][j-1];
	}
	int LCA(int x,int y)
	{
		if(le[x]>le[y]) swap(x,y);
		int l=len[le[y]-le[x]+1];
		if(dep[f[le[x]][l]]<dep[f[le[y]-bin[l]+1][l]]) return f[le[x]][l];
		else return f[le[y]-bin[l]+1][l];
	}
	void preit(vector<int> t) {for(int i=0;i<t.size();++i) if(!dfn[t[i]]) frdfs(t[i],0);init();}
	void ins(int x)
	{
		if(!tp) return st[++tp]=x,void();
		int lca=LCA(x,st[tp]);
		if(st[tp]==lca) return st[++tp]=x,void();
		L.pb(lca);
		while(tp>1&&dfn[lca]<=dfn[st[tp-1]]) H.link(st[tp-1],st[tp]),--tp;
		if(st[tp]^lca) H.link(lca,st[tp]),st[tp]=lca;
		st[++tp]=x;
	}
	void fktree(vector<int> t)
	{
		sort(t.begin(),t.end(),cmp);ins(t[0]);
		for(int i=1;i<t.size();++i)
		{
			if(is[t[i]]==is[t[i-1]]) ins(t[i]);
			else {while(tp>1) H.link(st[tp-1],st[tp]),--tp;tp=0;ins(t[i]);}
		}
		while(tp>1) H.link(st[tp-1],st[tp]),--tp;tp=0;
	}
}fkt;
int Rr;
int rotate(int element)
{
   element=(element+Rr)%n;
   if (element==0) element=n;
   return element;
}
int main()
{
//	freopen("ans.in","r",stdin);
//	freopen("c.out","w",stdout);
	read(n),read(m),read(q);
	for(int i=1;i<=n;++i) is[i]=i;
	for(int i=1,x,y;i<=m;++i) read(x),read(y),G.link(x,y),is[find(x)]=find(y);
	for(int i=1;i<=n;++i) is[i]=find(i),F.pb(i);
	tj.init(F,G);tj.getbl(F,G);
	for(int i=1;i<=n;++i) bl[i]=tj.bl[i];
	tj.clear(F,G);
	for(int i=2;i<=G.tot;i+=2) if(bl[G.e[i].u]!=bl[G.e[i].t]) T.link(bl[G.e[i].u],bl[G.e[i].t]);
	F.clear();
	for(int i=1;i<=n;++i) if(bl[i]==i) F.pb(i);
	fkt.preit(F);
	for(int i=1,V,E;i<=q;++i)
	{
		read(V),read(E);F.resize(V);H.clear();R.clear();
		for(int i=0;i<V;++i) read(F[i]),F[i]=rotate(F[i]),F[i]=bl[F[i]];R=F;
		for(int i=1,x,y;i<=E;++i)
		{
			read(x),read(y);x=rotate(x);y=rotate(y);
			if(bl[x]!=bl[y]) H.link(bl[x],bl[y]),F.pb(bl[x]),F.pb(bl[y]);
		}
		sort(F.begin(),F.end());F.resize(unique(F.begin(),F.end())-F.begin());L=F;
		sort(R.begin(),R.end());R.resize(unique(R.begin(),R.end())-R.begin());
		fkt.fktree(F);
		sort(L.begin(),L.end());L.resize(unique(L.begin(),L.end())-L.begin());
		tj.init(L,H);tj.getbl(L,H);
		puts(!tj.jud(R)?"NO":((Rr+=i)%=n,"YES"));
		tj.clear(L,H);
	}
	return 0;
}
/*
6 5 4
1 2
2 3
3 4
2 4
5 6

2 0
4 2

2 1
6 2
3 4

3 2
6 3 4
2 5
4 6

2 1
1 2
1 2

7 6 2
1 2
1 3
2 4
2 5
3 6
3 7

7 2
1 2 3 4 5 6 7
4 5
6 7

7 2
1 2 3 4 5 6 7
4 6
5 7

*/


#include <bits/stdc++.h>
using namespace std;
#define re register int
#define F(x, y, z) for (re x = y; x <= z; x++)
#define FOR(x, y, z) for (re x = y; x >= z; x--)
typedef long long ll;
#define I inline void
#define IN inline int
#define C(x, y) memset(x, y, sizeof(x))
#define STS system("pause")
template<class D> I read(D& res) {
	res = 0;
	register D g = 1;
	register char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') g = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	}
	res *= g;
}
#define T e[k].to
int n, m, Q, X, Y, R, _n, _m, sum, now;
int d[303000], ned[303000], a[303000];
struct Graph {
	vector<int> v[303000];
	int root[303000], dep[303000], id[303000], son[303000], siz[303000], top[303000], ma[303000];
	int head[303000], tot;
	int vis[303000], dfn[303000], low[303000], clr[303000], color, mill;
	int sn;
	stack<int> s;
	struct E {
		int to, nt;
	} e[606000];
	I addin(int x, int y) { v[y].emplace_back(x); }
	I add(int x, int y) {
		e[++tot].to = y;
		e[tot].nt = head[x];
		head[x] = tot;
	}
	I tarjan(int x, int fa) {
		dfn[x] = low[x] = ++mill;
		vis[x] = 1;
		s.emplace(x);
		for (re k = head[x]; k != -1; k = e[k].nt) {
			if (k == (fa ^ 1)) continue;
			if (!dfn[T]) {
				tarjan(T, k);
				low[x] = min(low[T], low[x]);
			} else if (vis[T])
				low[x] = min(low[x], dfn[T]);
		}
		if (dfn[x] == low[x]) {
			++color;
			while (s.top() != x) clr[s.top()] = color, vis[s.top()] = 0, s.pop();
			clr[x] = color;
			vis[x] = 0;
			s.pop();
		}
	}
	I D_1(int x, int fa, int depth, int Root) {
		ma[x] = fa;
		dep[x] = depth;
		son[x] = -1;
		root[x] = Root;
		siz[x] = 1;
		re maxi = -1;
		for (auto p : v[x]) {
			if (p == fa) continue;
			D_1(p, x, depth + 1, Root);
			siz[x] += siz[p];
			if (maxi < siz[p]) maxi = siz[p], son[x] = p;
		}
	}
	I D_2(int x, int fa, int topi) {
		top[x] = topi;
		id[x] = ++sum;
		if (son[x] != -1) D_2(son[x], x, topi);
		for (auto p : v[x]) {
			if (p == fa || p == son[x]) continue;
			D_2(p, x, p);
		}
	}
	IN ques_lca(int x, int y) {
		while (top[x] != top[y]) {
			if (dep[top[x]] < dep[top[y]]) swap(x, y);
			x = ma[top[x]];
		}
		if (dep[x] > dep[y]) swap(x, y);
		return x;
	}
	I build() {
		tot = -1;
		C(head, -1);
		F(i, 1, m) {
			read(X);
			read(Y);
			add(X, Y);
			add(Y, X);
		}
		F(i, 1, n) if (!dfn[i]) tarjan(i, -1);
		F(i, 1, n) for (re k = head[i]; k != -1; k = e[k].nt) if (clr[i] != clr[T]) addin(clr[i], clr[T]);
		F(i, 1, color) if (!root[i]) D_1(i, 0, 1, i), D_2(i, 0, i);
	}
	I solve() {
		sn = 1;
		F(i, 1, now) if (!dfn[a[i]]) tarjan(a[i], -1);
		F(i, 2, _n)
		if (clr[d[i]] != clr[d[1]]) {
			sn = 0;
			break;
		}
		if (sn)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
		F(i, 1, now) head[a[i]] = -1, dfn[a[i]] = low[a[i]] = clr[a[i]] = ned[a[i]] = 0, mill = color = 0;
	}
} G, g;
inline bool bbb(int x, int y) { return G.id[x] < G.id[y]; }
int q[303000], r;
int main() {
	read(n);
	read(m);
	read(Q);
	sum = 0;
	C(g.head, -1);
	G.build();
	F(t, 1, Q) {
		read(_n);
		read(_m);
		sum = 0;
		g.tot = -1;
		F(i, 1, _n) {
			read(d[i]);
			d[i] = G.clr[d[i]];
			if (!ned[d[i]]) ned[d[i]] = 1, a[++sum] = d[i];
		}
		F(i, 1, _m) {
			read(X);
			read(Y);
			X = G.clr[X];
			Y = G.clr[Y];
			g.add(X, Y);
			g.add(Y, X);
			if (!ned[X]) ned[X] = 1, a[++sum] = X;
			if (!ned[Y]) ned[Y] = 1, a[++sum] = Y;
		}
		sort(a + 1, a + 1 + sum, bbb);
		r = 0;
		now = sum;
		F(i, 1, sum) {
			if (!r || G.root[q[r]] != G.root[a[i]]) {
				while (r > 1) g.add(q[r], q[r - 1]), g.add(q[r - 1], q[r]), r--;
				q[r = 1] = G.root[a[i]];
				if (!ned[G.root[a[i]]])
					ned[G.root[a[i]]] = 1, a[++now] = G.root[a[i]];
				else
					continue;
			}
			re lca = G.ques_lca(q[r], a[i]);
			while (G.id[q[r]] > G.id[lca]) {
				if (G.id[q[r - 1]] > G.id[lca])
					g.add(q[r - 1], q[r]), g.add(q[r], q[r - 1]), r--;
				else
					g.add(lca, q[r]), g.add(q[r], lca), q[r] = lca, a[++now] = lca;
			}
			q[++r] = a[i];
		}
		while (r > 1) g.add(q[r], q[r - 1]), g.add(q[r - 1], q[r]), r--;
		g.solve();
	}
	return 0;
}


#include<bits/stdc++.h>
#define pb(a) push_back(a)
using namespace std;
inline void read(int &x)
{
	x=0;char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+c-48,c=getchar();
}
const int maxn=1e6+5;
int n,m,q,ct,dfn[maxn],bl[maxn],is[maxn];
vector<int> F,R;
int find(int x) {return is[x]==x?x:is[x]=find(is[x]);}
struct Graph{
	int tot=1,first[maxn];
	struct Road{int u,t,nxt;}e[maxn];
	void add(int x,int y) {e[++tot]=(Road){x,y,first[x]};first[x]=tot;}
	void link(int x,int y) {add(x,y);add(y,x);}
	void clear() {for(int i=2;i<=tot;++i) first[e[i].u]=0;tot=1;}
}G,T,H;
struct Tarjan{
	int rg,n,ct,dex,low[maxn],dfn[maxn],bl[maxn],bri[maxn],yet[maxn],fat[maxn];
	int find(int x) {return x==fat[x]?x:fat[x]=find(fat[x]);}
	void tarjan(int x,int f,Graph &G)
	{
		dfn[x]=low[x]=++dex;
		for(int i=G.first[x],t;i;i=G.e[i].nxt)
			if(i^f^1)
			{
				t=G.e[i].t;
				if(!dfn[t]) tarjan(t,i,G),low[x]=min(low[t],low[x]),bri[i]=bri[i^1]=low[t]>dfn[x];
				else low[x]=min(low[x],dfn[t]);
			}
	}
	void getbl(vector<int> t,Graph &G)
	{
		for(int i=0;i<t.size();++i) fat[t[i]]=t[i];
		for(int i=2;i<=G.tot;i+=2) if(!bri[i]) fat[find(G.e[i].u)]=find(G.e[i].t);
		for(int i=0;i<t.size();++i) bl[t[i]]=find(t[i]);
	}
	void init(vector<int> t,Graph &G)
	{
		n=t.size()-1;
		for(int i=0;i<=n;++i) if(!dfn[t[i]]) tarjan(t[i],0,G);
	}
	void clear(vector<int> t,Graph &G)
	{
		n=ct=dex=rg=0;
		for(int i=0;i<t.size();++i) dfn[t[i]]=low[t[i]]=bl[t[i]]=yet[t[i]]=fat[t[i]]=0;
		for(int i=0;i<=G.tot;++i) bri[i]=0;
	}
	int jud(vector<int> t)
	{
		int g=bl[t[0]];
		for(int i=1;i<t.size();++i) if(g!=bl[t[i]]) return 0;
		return 1;
	}
}tj;
int cmp(int a,int b) {return dfn[a]<dfn[b];}
struct Fake_Tree{
	int dex,ct,tp,st[maxn],le[maxn],dep[maxn];
	int p,bin[20],len[maxn],f[maxn][20];
	void frdfs(int x,int fa)
	{
		dep[x]=dep[fa]+1;dfn[x]=++dex;f[le[x]=++ct][0]=x;
		for(int i=T.first[x],t;i;i=T.e[i].nxt)
			if(T.e[i].t!=fa)
				frdfs(T.e[i].t,x),f[++ct][0]=x;
	}
	void init()
	{
		p=log(ct)/log(2)+1;
		for(int i=bin[0]=1;i<=p;++i) bin[i]=bin[i-1]<<1;
		for(int i=1;i<=ct;++i) len[i]=log(i)/log(2);
		for(int j=1;j<=p;++j)
			for(int i=1;i+bin[j]-1<=ct;++i)
				if(dep[f[i][j-1]]<dep[f[i+bin[j-1]][j-1]]) f[i][j]=f[i][j-1];
				else f[i][j]=f[i+bin[j-1]][j-1];
	}
	int LCA(int x,int y)
	{
		if(le[x]>le[y]) swap(x,y);
		int l=len[le[y]-le[x]+1];
		if(dep[f[le[x]][l]]<dep[f[le[y]-bin[l]+1][l]]) return f[le[x]][l];
		else return f[le[y]-bin[l]+1][l];
	}
	void preit(vector<int> t) {for(int i=0;i<t.size();++i) if(!dfn[t[i]]) frdfs(t[i],0);init();}
	void ins(int x)
	{
		if(!tp) return st[++tp]=x,void();
		int lca=LCA(x,st[tp]);
		if(st[tp]==lca) return st[++tp]=x,void();
		while(tp>1&&dfn[lca]<=dfn[st[tp-1]]) H.link(st[tp-1],st[tp]),--tp;
		if(st[tp]^lca) H.link(lca,st[tp]),st[tp]=lca;
		st[++tp]=x;
	}
	void fktree(vector<int> t)
	{
		sort(t.begin(),t.end(),cmp);ins(t[0]);
		for(int i=1;i<t.size();++i)
		{
			if(is[t[i]]==is[t[i-1]]) ins(t[i]);
			else {while(tp>1) H.link(st[tp-1],st[tp]),--tp;tp=0;ins(t[i]);}
		}
		while(tp>1) H.link(st[tp-1],st[tp]),--tp;tp=0;
	}
}fkt;
int main()
{
	read(n),read(m),read(q);
	for(int i=1;i<=n;++i) is[i]=i;
	for(int i=1,x,y;i<=m;++i) read(x),read(y),G.link(x,y),is[find(x)]=find(y);
	for(int i=1;i<=n;++i) is[i]=find(i),F.pb(i);
	tj.init(F,G);tj.getbl(F,G);
	for(int i=1;i<=n;++i) bl[i]=tj.bl[i];
	tj.clear(F,G);
	for(int i=2;i<=G.tot;i+=2) if(bl[G.e[i].u]!=bl[G.e[i].t]) T.link(bl[G.e[i].u],bl[G.e[i].t]);
	F.clear();
	for(int i=1;i<=n;++i) if(bl[i]==i) F.pb(i);
	fkt.preit(F);
	for(int i=1,V,E;i<=q;++i)
	{
		read(V),read(E);F.resize(V);H.clear();
		for(int i=0;i<V;++i) read(F[i]),F[i]=bl[F[i]];R=F;
		for(int i=1,x,y;i<=E;++i)
		{
			read(x),read(y);F.pb(bl[x]);F.pb(bl[y]);
			if(bl[x]!=bl[y]) H.link(bl[x],bl[y]);
		}
		sort(F.begin(),F.end());F.resize(unique(F.begin(),F.end())-F.begin());
		sort(R.begin(),R.end());R.resize(unique(R.begin(),R.end())-R.begin());
		fkt.fktree(F);tj.init(F,H);tj.getbl(F,H);
		puts(!tj.jud(R)?"NO":"YES");
		tj.clear(F,H);
	}
	return 0;
}
/*
6 5 4
1 2
2 3
3 4
2 4
5 6

2 0
4 2

2 1
6 2
3 4

3 2
6 3 4
2 5
4 6

2 1
1 2
1 2

7 6 2
1 2
1 3
2 4
2 5
3 6
3 7

7 2
1 2 3 4 5 6 7
4 5
6 7

7 2
1 2 3 4 5 6 7
4 6
5 7

*/


#include <cstdio>
#include <algorithm>
#include <vector>

typedef std::pair<int, int> pii;
const int MN = 300005;

int N, M, Q;
std::vector<pii> G[MN];
std::vector<int> T[MN];

int stk[MN], tp;
int dfn[MN], low[MN], dfc;
int idu[MN], bel[MN], cnt;
int faz[MN];
void Tarjan(int u, int li) {
	low[u] = dfn[u] = ++dfc;
	stk[++tp] = u;
	for (auto e : G[u]) {
		int v = e.first, i = e.second;
		if (!dfn[v]) {
			faz[v] = u;
			Tarjan(v, i);
			low[u] = std::min(low[u], low[v]);
			if (low[v] > dfn[u]) {
				idu[++cnt] = v;
				for (int x = 0; x != v; --tp) {
					x = stk[tp];
					bel[x] = cnt;
				}
			}
		} else if (i != li) low[u] = std::min(low[u], dfn[v]);
	}
}

int tfaz[MN], dep[MN], siz[MN], son[MN], tdfn[MN], top[MN], tdfc;
void DFS0(int u, int f) {
	dep[u] = dep[tfaz[u] = f] + 1;
	siz[u] = 1;
	for (auto v : T[u]) {
		DFS0(v, u);
		siz[u] += siz[v];
		if (siz[son[u]] < siz[v]) son[u] = v;
	}
}
void DFS1(int u, int t) {
	tdfn[u] = ++tdfc;
	top[u] = t;
	if (son[u]) DFS1(son[u], t);
	for (auto v : T[u]) if (v != son[u]) DFS1(v, v);
}
inline int lca(int x, int y) {
	while (top[x] != top[y]) {
		if (dep[top[x]] < dep[top[y]]) std::swap(x, y);
		x = tfaz[top[x]];
		if (!x) return 0;
	}
	return dep[x] < dep[y] ? x : y;
}

int _bel[MN];

int main() {
	scanf("%d%d%d", &N, &M, &Q);
	for (int i = 1, x, y; i <= M; ++i) {
		scanf("%d%d", &x, &y);
		if (x != y)
			G[x].push_back({y, i}),
			G[y].push_back({x, i});
	}
	for (int i = 1; i <= N; ++i) if (!dfn[i]) {
		Tarjan(i, 0);
		idu[++cnt] = i;
		while (tp) bel[stk[tp--]] = cnt;
	}
	for (int i = 1; i <= cnt; ++i)
		if (faz[idu[i]]) T[bel[faz[idu[i]]]].push_back(i);
		else DFS0(i, 0), DFS1(i, i);
	for (int i = 1; i <= N; ++i) _bel[i] = bel[i];
	long long Rval = 0;
	for (int q = 1; q <= Q; ++q) {
		int n, m, c = 0;
		static int x[MN], a[MN], b[MN], d[MN * 3];
		scanf("%d%d", &n, &m);
		for (int i = 1; i <= n; ++i) {
			scanf("%d", &x[i]);
			x[i] = (x[i] + Rval - 1) % N + 1;
			d[++c] = x[i] = _bel[x[i]];
		}
		for (int i = 1; i <= m; ++i) {
			scanf("%d%d", &a[i], &b[i]);
			a[i] = (a[i] + Rval - 1) % N + 1;
			b[i] = (b[i] + Rval - 1) % N + 1;
			d[++c] = a[i] = _bel[a[i]];
			d[++c] = b[i] = _bel[b[i]];
		}
		std::sort(d + 1, d + c + 1, [](int i, int j) { return tdfn[i] < tdfn[j]; });
		c = std::unique(d + 1, d + c + 1) - d - 1;
		static int vstk[MN]; int vtp = 0, edg = 0, X;
		for (int i = 1; i <= c; ++i) {
			int u = d[i];
			G[u].clear(), dfn[u] = 0;
			if (!vtp) vstk[vtp = 1] = u;
			else {
				int l = lca(vstk[vtp], u);
				if (!l) {
					for (X = 0; vtp; X = vstk[vtp--]) if (X)
						G[vstk[vtp]].push_back({X, ++edg}),
						G[X].push_back({vstk[vtp], edg});
					vstk[vtp = 1] = u;
					continue;
				}
				for (X = 0; vtp && dep[vstk[vtp]] > dep[l]; X = vstk[vtp--]) if (X)
					G[vstk[vtp]].push_back({X, ++edg}),
					G[X].push_back({vstk[vtp], edg});
				if (!vtp || vstk[vtp] != l) vstk[++vtp] = l, G[l].clear(), dfn[l] = 0;
				if (X)
					G[vstk[vtp]].push_back({X, ++edg}),
					G[X].push_back({vstk[vtp], edg});
				vstk[++vtp] = u;
			}
		}
		for (X = 0; vtp; X = vstk[vtp--]) if (X)
			G[vstk[vtp]].push_back({X, ++edg}),
			G[X].push_back({vstk[vtp], edg});
		for (int i = 1; i <= m; ++i)
			if (a[i] != b[i])
				G[a[i]].push_back({b[i], ++edg}),
				G[b[i]].push_back({a[i], edg});
		cnt = 0;
		for (int i = 1; i <= n; ++i) if (!dfn[x[i]]) {
			Tarjan(x[i], 0);
			idu[++cnt] = x[i];
			while (tp) bel[stk[tp--]] = cnt;
		}
		int ok = 1;
		for (int i = 1; i <= n; ++i)
			if (bel[x[i]] != bel[x[1]]) { ok = 0; break; }
		if (ok) puts("YES"), Rval += q;
		else puts("NO");
	}
	return 0;
}

// Luogu : PinkRabbit


#include<bits/stdc++.h>
using namespace std;
inline int gi()
{
	char c=getchar(); int x=0;
	for(;c<'0'||c>'9';c=getchar());
	for(;c>='0'&&c<='9';c=getchar())x=(x<<1)+(x<<3)+c-'0';
	return x;
}
const int N=3e5+5;
int n,m,q,R,stk[N*3],tp;
vector<int> ask,vec,iee;
vector<pair<int,int>> ee;
int rot(int ele)
{
	ele=(ele+R)%n;
	if(!ele) ele=n;
	return ele;
}
struct graph
{
	vector<pair<int,int>> e[N];
	int dfn[N],low[N],st[N],tp,tid,scc,bel[N],tot,v;
	bool ins[N];
	void adde(int u, int v)
	{
		e[u].push_back(make_pair(v,++tot));
		e[v].push_back(make_pair(u,tot));
	}
	void tarjan(int u, int fa)
	{
		dfn[u]=low[u]=++tid;
		ins[u]=true,st[++tp]=u;
		for(auto x:e[u]) if(x.second!=fa)
		{
			const int v=x.first;
			if(!dfn[v]) tarjan(v,x.second),low[u]=min(low[u],low[v]);
			else if(ins[v]) low[u]=min(low[u],dfn[v]);
		}
		if(low[u]==dfn[u])
		{
			++scc;
			while(true)
			{
				bel[st[tp--]]=scc,ins[st[tp+1]]=false;
				if(st[tp+1]==u) break;
			}
		}
	}
	void tarjin()
	{
		for(auto x:vec) if(!dfn[x]) tarjan(x,0);
	}
	void reset()
	{
		tp=tid=scc=tot=0;
		for(auto x:vec) dfn[x]=low[x]=bel[x]=ins[x]=0,e[x].clear();
		iee.clear();
	}
} g1,g2;
struct tree
{
	vector<int> e[N];
	int fa[N],dep[N],top[N],son[N],sze[N],dfn[N],tid,ed[N],bel[N],cid;
	void adde(int u, int v)
	{
		e[u].push_back(v),e[v].push_back(u);
	}
	void dfs(int u)
	{
		sze[u]=1,bel[u]=cid;
		for(auto v:e[u]) if(v!=fa[u])
		{
			dep[v]=dep[u]+1;
			fa[v]=u,dfs(v);
			sze[u]+=sze[v];
			if(sze[v]>sze[son[u]]) son[u]=v;
		}
	}
	void dfs2(int u, int tp)
	{
		top[u]=tp,dfn[u]=++tid;
		if(son[u]) dfs2(son[u],tp);
		for(auto v:e[u]) if(v!=fa[u]&&v!=son[u]) dfs2(v,v);
		ed[u]=tid;
	}
	inline int lca(int u, int v)
	{
		if(bel[u]!=bel[v]) return 0;
		while(top[u]^top[v])
			dep[top[u]]>dep[top[v]]?u=fa[top[u]]:v=fa[top[v]];
		return dep[u]<dep[v]?u:v;
	}
	void init()
	{
		for(int u=1;u<=n;++u)
			sort(e[u].begin(),e[u].end()),e[u].erase(unique(e[u].begin(),e[u].end()),e[u].end());
		for(int u=1;u<=n;++u) if(!bel[u]) bel[u]=++cid,dfs(u),dfs2(u,u);
	}
} gt;
int main()
{
	n=gi(),m=gi(),q=gi();
	for(int i=1;i<=m;++i) g1.adde(gi(),gi());
	for(int i=1;i<=n;++i) vec.push_back(i);
	g1.tarjin(),vec.clear();
	for(int u=1;u<=n;++u)
		for(auto x:g1.e[u])
			if(g1.bel[u]!=g1.bel[x.first]) gt.adde(g1.bel[u],g1.bel[x.first]);
	gt.init();
	for(int i=1;i<=q;++i)
	{
		vec.clear(),ask.clear(),ee.clear();
		int ni=gi(),mi=gi();
		for(int i=1;i<=ni;++i)
		{
			int x=g1.bel[rot(gi())];
			ask.push_back(x),vec.push_back(x),iee.push_back(x);
		}
		for(int i=1;i<=mi;++i)
		{
		    int u=g1.bel[rot(gi())],v=g1.bel[rot(gi())];
			if(u!=v) vec.push_back(u),vec.push_back(v),ee.push_back(make_pair(u,v));
		}
		sort(vec.begin(),vec.end(),[&](int x, int y){
			return gt.dfn[x]<gt.dfn[y];
		});
		vec.erase(unique(vec.begin(),vec.end()),vec.end());
		for(int i=1,l=vec.size();i<l;++i) vec.push_back(gt.lca(vec[i-1],vec[i])),
		sort(vec.begin(),vec.end(),[&](int x, int y){
			return gt.dfn[x]<gt.dfn[y];
		});
		vec.erase(unique(vec.begin(),vec.end()),vec.end());
		int tp=0;
		for(auto x:vec)
		{
			for(;tp&&gt.ed[stk[tp]]<gt.dfn[x];--tp);
			if(tp) g2.adde(stk[tp],x);
			stk[++tp]=x;
		}
		for(auto x:ee) g2.adde(x.first,x.second);
		g2.tarjin();
		bool flag=true;
		for(int i=1;flag&&i<ask.size();++i) if(g2.bel[ask[i]]!=g2.bel[ask[0]]) flag=false;
		if(flag) puts("YES"),R=(R+i)%n;
		else puts("NO");
		g2.reset();
	}
}


#include<bits/stdc++.h>
using namespace std;

vector<int>T[300005];

int n,m,q,R,cnt,tot,tim;
int head[300005],to[600005],cut[600005],from[600005],Next[600005];
int P[300005],A[300005],fa[300005],rt[300005],Col[300005],col[300005],vis[300005],dfn[300005],low[300005],son[300005],top[300005],dep[300005],rnk[300005],size[300005];

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){
       if(ch=='-')f=-1;
       ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
       x=(x<<1)+(x<<3)+ch-'0';
       ch=getchar();
    }
    return x*f;
}

inline int Get(int x){
    return (x+R>n?x+R-n:x+R);
}

inline void add(int u,int v){
    to[++cnt]=v;from[cnt]=u;Next[cnt]=head[u];head[u]=cnt;
}

inline bool Cmp(int x,int y){
    return rnk[x]<rnk[y];
}

int LCA(int x,int y){
    int fx=top[x],fy=top[y];
    while(fx!=fy){
        if(dep[fx]<dep[fy]){
            swap(x , y);
            swap(fx,fy);
        }
        x=fa[fx];fx=top[x];
    }
    return dep[x]<dep[y]?x:y;
}

void Tarjan(int u,int E){
    dfn[u]=low[u]=++tim;
    for(register int i=head[u];~i;i=Next[i]){
        int v=to[i];
        if(i==E)
            continue;
        if(!dfn[v]){
            Tarjan(v,i^1);
            low[u]=min(low[u],low[v]);
            if(low[v]>dfn[u]){
                cut[i^0]=1;
                cut[i^1]=1;
            }
        }
        else
            low[u]=min(low[u],dfn[v]);
    }
    return;
}

void Dfs(int u,int op){
    if(op==0)
        Col[u]=tot;
    if(op==1)
        col[u]=tot;
    for(register int i=head[u];~i;i=Next[i]){
        int v=to[i];
        if(!cut[i]){
            if(op==0&&!Col[v])
                Dfs(v,op);
            if(op==1&&!col[v])
                Dfs(v,op);
        }
    }
    return;
}

void dfs1(int u,int f){
    rt[u]=rt[f];
    dep[u]=dep[fa[u]=f]+(size[u]=1);
    for(register int i=0;i<T[u].size();++i){
        int v=T[u][i];
        if(v!=f){
            dfs1(v,u);
            size[u]+=size[v];
            son[u]=size[v]>size[son[u]]?v:son[u];
        }
    }
    return;
}

void dfs2(int u,int f){
    rnk[u]=++tim;
    if(son[u]){
        top[son[u]]=top[u];
        dfs2(son[u],u);
    }
    for(register int i=0;i<T[u].size();++i){
        int v=T[u][i];
        if(!top[v]){
            top[v]=v;
            dfs2(v,u);
        }
    }
    return;
}

int solve(int V,int n){

    static int N,top,s[600005];

    N=n;tot=0;top=0;tim=0;

    sort(A+1,A+1+n,Cmp);

    for(register int i=1;i<=n;++i){
        if(!top||rt[s[top]]!=rt[A[i]]){
            while(top>1){
                add(s[top],s[top-1]);
                add(s[top-1],s[top]);
                --top;
            }
            s[top=1]=rt[A[i]];
            if(!vis[rt[A[i]]]){
                vis[rt[A[i]]]=1;
                A[++N]=rt[A[i]];
            }
            else
                continue;
        }
        int Lca=LCA(s[top],A[i]);
        while(rnk[s[top]]>rnk[Lca]){
            if(rnk[s[top-1]]>rnk[Lca]){
                add(s[top],s[top-1]);
                add(s[top-1],s[top]);
                --top;
            }
            else{
                add(Lca,s[top]);
                add(s[top],Lca);
                s[top]=Lca;
                if(!vis[Lca]){
                    vis[Lca]=1;
                    A[++N]=Lca;
                }
            }
        }
        s[++top]=A[i];
    }
    while(top>1){
        add(s[top],s[top-1]);
        add(s[top-1],s[top]);
        --top;
    }

    for(register int i=1;i<=N;++i){
        if(!dfn[A[i]])
            Tarjan(A[i],-1);
    }

    for(register int i=1;i<=N;++i){
        if(!col[A[i]]){
            ++tot;
            Dfs(A[i],1);
        }
    }

    int flag=1;

    for(register int i=1;i<=V;++i){
        if(col[P[1]]!=col[P[i]]){
            flag=0;
            break;
        }
    }

    for(register int i=1;i<=N;++i)
        vis[A[i]]=dfn[A[i]]=col[A[i]]=0;

    for(register int i=0;i<=cnt;++i){
        cut[i]=0;
        head[to[i]]=-1;
    }

    return flag;
}

int main(){

    cnt=-1;
    memset(head,-1,sizeof head);

    n=read();m=read();q=read();

    for(register int i=1;i<=m;++i){
        int u,v;
        u=read();v=read();
        add(u,v);add(v,u);
    }

    for(register int i=1;i<=n;++i){
        if(!dfn[i])
            Tarjan(i,-1);
    }

    for(register int i=1;i<=n;++i){
        if(!Col[i]){
            ++tot;
            Dfs(i,0);
        }
    }

    for(register int i=0;i<=cnt;++i){
        if(Col[from[i]]!=Col[to[i]])
            T[Col[from[i]]].push_back(Col[to[i]]);
    }

    tim=0;
    for(register int i=1;i<=tot;++i){
        if(!rt[i]){
            top[i]=rt[i]=i;
            dfs1(i,i);dfs2(i,i);
        }
    }

    memset(cut , 0,sizeof cut );
    memset(dfn , 0,sizeof dfn );
    memset(head,-1,sizeof head);

    for(register int Q=1;Q<=q;++Q){

        int V=read();
        int E=read();

        int N=0;cnt=-1;

        for(register int i=1;i<=V;++i){
            P[i]=Col[Get(read())];
            if(!vis[P[i]]){
                vis[P[i]]=1;
                A[++N]=P[i];
            }
        }

        for(register int i=1;i<=E;++i){
            int u=Col[Get(read())];
            int v=Col[Get(read())];
            add(u,v);add(v,u);
            if(!vis[u]){
                vis[u]=1;
                A[++N]=u;
            }
            if(!vis[v]){
                vis[v]=1;
                A[++N]=v;
            }
        }

        if(solve(V,N)){
            R=(R+Q)%n;
            printf("YES\n");
        }
        else
            printf("NO\n");
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int read()
{
    int r=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')r=(r<<1)+(r<<3)+ch-'0',ch=getchar();
    return r*f;
}
int n,m,Q;
int R;
int rotate(int element)
{
   element=(element+R)%n;
   if (element==0) {
       element=n;
   }
   return element;
}
struct data{
    int to,nxt;
};
int lg[300300],ll;
int bel[300300];
struct Graph{
    data mp[600600];
    int head[300300],cnt;
    void link(int x,int y)
    {
        mp[++cnt].to=y;
        mp[cnt].nxt=head[x];
        head[x]=cnt;
    }
    void add(int x,int y)
    {
        link(x,y),link(y,x);
    }

    int dfn[300300],clk;
    int low[300300];
    int st[300300],ts;
    int col[300300],tcol;
    int e[300300][2],te;
    void Tarjan(int x,int fa,int fi)
    {
        low[x]=dfn[x]=++clk;
        st[++ts]=x;
        int v;
        for(int i=head[x];i;i=mp[i].nxt)
            if(fi!=i&&fi!=(i^1))
            {
                v=mp[i].to;
                if(!dfn[v])Tarjan(v,x,i),low[x]=min(low[x],low[v]);
                else low[x]=min(low[x],dfn[v]);
            }
        if(low[x]==dfn[x])
        {
            tcol++;
            if(fa)e[++te][0]=x,e[te][1]=fa;
            while(st[ts+1]!=x)
            {
                st[ts+1]=0;
                col[st[ts]]=tcol,ts--;
            }
            st[ts+1]=0;
        }
    }
    int f[300300][22];
    int dep[300300];
    void dfs(int x,int r)
    {
        dfn[x]=++clk;
        bel[x]=r;
        dep[x]=dep[f[x][0]]+1;
        for(int i=1;i<=20;++i)f[x][i]=f[f[x][i-1]][i-1];
        for(int i=head[x];i;i=mp[i].nxt)
            if(mp[i].to!=f[x][0])
            {
                f[mp[i].to][0]=x;
                dfs(mp[i].to,r);
            }
    }
    void rebuild()
    {
        memset(head,0,sizeof(head));cnt=0;
        int x,y;
        for(int i=1;i<=te;++i)
            add(col[e[i][0]],col[e[i][1]]);
        memset(dfn,0,sizeof(dfn));clk=0;
        for(int i=1;i<=tcol;++i)
            if(!dfn[i])dfs(i,i);
    }
    int LCA(int x,int y)
    {
        if(dep[x]>dep[y])swap(x,y);
        while(dep[y]!=dep[x])y=f[y][lg[dep[y]-dep[x]]];
        if(x==y)return x;
        for(int i=20;i>=0;--i)
            if(f[x][i]!=f[y][i])x=f[x][i],y=f[y][i];
        return f[x][0];
    }
}g1,g2;

int ni,mi;
int p[300300],tp;
int ed[300300][2],ted;
bool book[300300];
int nd[300300],tnd;
bool cmp(int a,int b){return g1.dfn[a]<g1.dfn[b];}
int sta[300300],top;
int ext[300300],tex;
void build_vtree()
{
    for(int i=1;i<=tnd;++i)
        if(!book[bel[nd[i]]])book[bel[nd[i]]]=1,nd[++tnd]=bel[nd[i]];
    sort(nd+1,nd+tnd+1,cmp);
    int x,lca;
    for(int i=1,j;i<=tnd;i=j)
    {
        sta[top=1]=nd[i];
        for(j=i+1;bel[nd[j]]==bel[nd[i]]&&j<=tnd;++j)
        {
            x=nd[j];
            lca=g1.LCA(sta[top],x);
            if(!book[lca])book[lca]=1,ext[++tex]=lca;
            if(lca==sta[top])
            {
                sta[++top]=x;
                continue;
            }
            while(g1.dep[sta[top-1]]>g1.dep[lca])
            {
                g2.add(sta[top],sta[top-1]);
                top--;
            }
            g2.add(sta[top],lca); top--;
            if(sta[top]!=lca)sta[++top]=lca;
            sta[++top]=x;
        }
        while(top>1)
        {
            g2.add(sta[top],sta[top-1]);
            top--;
        }
        top=0;
    }
}
void reset()
{
    int x;
    g2.cnt=1;
    g2.tcol=g2.ts=g2.clk=g2.te=0;
    for(int i=1;i<=tnd;++i)
    {
        x=nd[i];
        g2.head[x]=g2.dfn[x]=g2.low[x]=g2.col[x]=0;
        book[x]=0;
    }
    for(int i=1;i<=tex;++i)
    {
        x=ext[i];
        g2.head[x]=g2.dfn[x]=g2.low[x]=g2.col[x]=0;
        book[x]=0;
    }
    tex=0;
}
int main()
{
    n=read(),m=read(),Q=read();
    for(int i=1;i<=n;++i)lg[i]=(i==(1<<(ll+1)))?++ll:ll;
    int xx,yy;
    g1.cnt=1;
    for(int i=1;i<=m;++i)
    {
        xx=read(),yy=read();
        g1.link(xx,yy);
        g1.link(yy,xx);
    }
    for(int i=1;i<=n;++i)
        if(!g1.dfn[i])g1.Tarjan(i,0,0);
    g1.rebuild();

    g2.cnt=1;
    int ID=0;
    while(Q--)
    {
        ID++;
        ni=read(),mi=read();
        tnd=0;ted=0;
        tp=0;
        for(int i=1;i<=ni;++i)
        {
            xx=rotate(read());
            xx=g1.col[xx];
            if(book[xx])continue;
            book[xx]=1;
            nd[++tnd]=xx;
            p[++tp]=xx;
        }
        for(int i=1;i<=mi;++i)
        {
            xx=rotate(read());
            yy=rotate(read());
            xx=g1.col[xx];yy=g1.col[yy];
            if(xx==yy)continue;
            ed[++ted][0]=xx;ed[ted][1]=yy;
            if(!book[xx])book[xx]=1,nd[++tnd]=xx;
            if(!book[yy])book[yy]=1,nd[++tnd]=yy;
        }
        build_vtree();
        for(int i=1;i<=ted;++i)
            g2.add(ed[i][0],ed[i][1]);
        for(int i=1;i<=tnd;++i)
            if(!g2.dfn[nd[i]])g2.Tarjan(nd[i],0,0);
        int fl=1;
        for(int i=1;i<=tp;++i)
            if(g2.col[p[i]]!=g2.col[p[1]])
            {
                fl=0;
                break;
            }
        puts(fl?"YES":"NO");
        R+=fl*ID;
        R%=n;
        reset();
    }
    return 0;
}
//hellobig_tq


#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, 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){
	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 (v && (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], dn, dm, S[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){
		dn = k = read(), dm = read();
		int x, y;
		for (register int i = 1; i <= k; ++i)
			p[i] = S[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);
		bool flag = 1;
		for (register int i = 2; i <= dn; ++i)
			if (col[S[i]] != col[S[i - 1]]){ flag = 0; break; }
		if (flag) 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){
	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 (v && (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;
	}
}