//In the name of God

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

template<class P, class Q> inline P smin(P &a, Q b) { if (b < a) a = b; return a; }
template<class P, class Q> inline P smax(P &a, Q b) { if (a < b) a = b; return a; }

#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; i++)

const int N = 1e6 + 6, lg = 20;

int lastn, n, ss[N], tt[N], anc[N][lg], m, query_count, h[N], comp[N], used, mark[N], cut[N], st[N], ed[N], stamp, q[N], t, top, stk[N], dsu_comp[N], dsu[N], up[N], d[N], upmost[N];
vector<int> g[N];

int read() { int x; cin >> x; return x; }

int ycnt = 0;
int rotate(int &x) {
	x += ycnt;
	x %= lastn;
	if (!x)
		x = lastn;
	x--;
}

int find(int v, int *par) { return v == par[v]? v: par[v] = find(par[v], par); }
void unite(int u, int v, int *par, bool is = 0) {
	u = find(u, par);
	v = find(v, par);
	if (is && d[u] > d[v])
		swap(u, v);
	par[v] = u;
}

int dfs1(int v, int ep = -1) {
	if (mark[v]++)
		return h[v];
	int res = h[v];
	for (int e : g[v]) if (e != ep) {
		int u = ss[e] + tt[e] - v;
		if (h[u] == -1)
			h[u] = h[v] + 1;
		res = min(res, dfs1(u, e));
	}
//	cout << v << ' ' << h[v] << ' ' << res << endl;
	if (res == h[v] && ep != -1) {
		cut[ep] = 1;
	}
	return res;
}

void dfs2(int v, int cc) {
	if (mark[v]++)
		return;
	comp[v] = cc;
//	cout << v << " :D " << cc << endl;
	for (int e : g[v]) if (!cut[e]) {
		int u = ss[e] + tt[e] - v;
//		cout << v << " -> " << u << '\n';
		dfs2(u, cc);
	}
}

void dfs_lca(int v, int p) {
	if (p != v)
		h[v] = h[p] + 1;
	else
		h[v] = 0;
	st[v] = stamp++;
	anc[v][0] = p;
	for (int i = 1; i < lg; ++i)
		anc[v][i] = anc[anc[v][i - 1]][i - 1];
	for (int u : g[v]) if (u != p) {
		dfs_lca(u, v);
	}
	ed[v] = stamp;
}

void dfs4(int v, int p = -1) {
	mark[v] = 1;
//	cout << v << ' ' << p << endl;
	for (int u : g[v]) if (u != p) {
		d[u] = d[v] + 1;
		up[u] = v;
		dfs4(u, v);
	}
}

int lca(int u, int v) {
	if (h[u] < h[v])
		swap(u, v);
	rep(i, lg)
		if ((h[u] - h[v]) >> i & 1)
			u = anc[u][i];
	if (u == v)
		return v;
	for (int i = lg - 1; i >= 0; --i)
		if (anc[v][i] != anc[u][i])
			u = anc[u][i], v = anc[v][i];
	return anc[u][0] == anc[v][0]? anc[v][0]: -1;
}

bool ispar(int p, int v) { return (st[p] <= st[v]) && (st[v] < ed[p]); }
int cmp(int x, int y) { return st[x] < st[y]; }

int32_t main() {
	ios_base :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
	memset(anc, -1, sizeof anc);
	memset(h, -1, sizeof h);
	rep(i, N)
		dsu_comp[i] = i;
	n = read();
	lastn = n;
	m = read();
	query_count = read();
	rep(i, m) {
		int u = read() - 1, v = read() - 1;
		g[u].push_back(i);
		g[v].push_back(i);
		ss[i] = u;
		tt[i] = v;
	}
	rep(v, n) if (!mark[v]) {
		h[v] = 0;
		dfs1(v);
	}
	memset(mark, 0, sizeof mark);
	rep(v, n) if (!mark[v]) {
		dfs2(v, used);
		used++;
	}
//	return 0;
//	cout << '\n';
	rep(v, n) {
//		cout << v << ' ' << comp[v] << '\n';
		g[v].clear();
	}
	rep(e, m) {
		int u = ss[e], v = tt[e];
		u = comp[u];
		v = comp[v];
		if (u != v) {
			unite(u, v, dsu_comp);
			g[u].push_back(v);
			g[v].push_back(u);
		}
	}
	n = used; used = 0;
	memset(h, 0, sizeof h);
	rep(v, n) if (anc[v][0] == -1) {
		dfs_lca(v, v);
	}
	rep(v, n)
		g[v].clear();
//	return 0;
//	ycnt++;
	rep(qq, query_count) {
		rep(i, n) {
			dsu[i] = i;
			upmost[i] = i;
			g[i].clear();
			mark[i] = 0;
			d[i] = 0;
			up[i] = i;
		}
		t = 0;
		int ni = read(), mi = read();
		vector<int> imp, fav;
		vector<pair<int, int>> query, edges;
		rep(i, ni) {
			int v = read();
			rotate(v);
			v = comp[v];
			q[t++] = v;
			fav.push_back(v);
		}
		rep(i, mi) {
			int u = read(), v = read();
			rotate(u);
			rotate(v);
			u = comp[u];
			v = comp[v];
			edges.push_back({u, v});
			q[t++] = u;
			q[t++] = v;
		}
		sort(q, q + t);
		t = unique(q, q + t) - q;
		sort(q, q + t, cmp);
		int sz = t;
		rep(i, sz - 1) if (lca(q[i], q[i + 1]) != -1)
			q[t++] = lca(q[i], q[i + 1]);
		sort(q, q + t);
		t = unique(q, q + t) - q;
		sort(q, q + t, cmp);
		top = 0;
		rep(i, t) {
			int v = q[i];
			while (top > 0 && !ispar(stk[top - 1], v))
				top--;
			if (top)
				g[stk[top - 1]].push_back(v), g[v].push_back(stk[top - 1]);
			stk[top++] = v;
		}
		rep(i, t)
			dsu[find(q[i], dsu_comp)] = find(q[i], dsu_comp);

		for (auto e : edges) {
			int u = find(e.first, dsu_comp), v = find(e.second, dsu_comp);
			if (find(u, dsu) == find(v, dsu))
				query.push_back({e.first, e.second});
			else
				unite(u, v, dsu), g[e.first].push_back(e.second), g[e.second].push_back(e.first);
		}
		rep(i, t)
			mark[q[i]] = 0, upmost[q[i]] = q[i];
		rep(i, t) {
			int v = q[i];
			if (!mark[v]) {
				d[v] = 0;
				dfs4(v);
			}
		}
		rep(i, t)
			g[q[i]].clear();
		for (auto e : query) {
			int u = e.first, v = e.second;
//			cout << u << ' ' << v << endl;
			while (u != v) {
				u = find(u, upmost);
				v = find(v, upmost);
				if (u == v)
					break;
				if (d[u] > d[v])
					swap(u, v);
				unite(v, up[v], upmost, 1);
				v = find(v, upmost);
			}
		}
		int flag = 0;
		for (int i = 1; i < (int) fav.size(); ++i) {
			int u = fav[i - 1], v = fav[i];
			if (find(u, upmost) != find(v, upmost)) {
				cout << "NO\n";
				flag = 1;
				break;
			}
		}
		if (flag)
			continue;
		cout << "YES\n";
		ycnt += qq + 1; ycnt %= n;
	}
}
/*
6 5 1
1 2
2 3
3 4
2 4
5 6
3 2
6 3 4
2 5
4 6

2 1
6 2
3 4
*/


#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int maxn=300111;
int n,m,q;

struct tree
{
	int nxt[maxn<<1],to[maxn<<1],head[maxn],etot;
	int fa[20][maxn],dep[maxn],dfn[maxn],timer,seq[maxn],edfn[maxn];

	tree()
	{
		memset(head,0,sizeof(head));
		etot=1;
	}

	void addedge(int u,int v)
	{
		if(u==v)return;
		nxt[++etot]=head[u];head[u]=etot;
		to[etot]=v;
		nxt[++etot]=head[v];head[v]=etot;
		to[etot]=u;
	}

	void dfs(int x,int f,int d)
	{
		dfn[x]=++timer;seq[timer]=x;fa[0][timer]=f;dep[timer]=d;
		for(int i=1;i<20;i++)fa[i][timer]=fa[i-1][fa[i-1][timer]];

		for(int i=head[x];i;i=nxt[i])if(to[i]!=f)
			dfs(to[i],x,d+1);
		edfn[x]=timer;
	}

	int getlca(int u,int v)//x -> dfn[x]
	{
		if(dep[u]<dep[v])swap(u,v);
		for(int i=19;i>=0;i--)if(dep[u]-dep[v]>>i)u=fa[i][u];
		if(u==v)return u;
		for(int i=19;i>=0;i--)if(fa[i][u]!=fa[i][v])
		{
			u=fa[i][u];
			v=fa[i][v];
		}
		return fa[0][u];
	}

	void prework(int n)
	{
		timer=0;
		for(int i=1;i<=n;i++)if(!dfn[i])
			dfs(i,0,1);
	}

	int stk[maxn],top;
	vector<pii> extract(vi&vs)
	{
		for(auto&x:vs)x=dfn[x];
		sort(vs.begin(),vs.end());
		for(int i=vs.size()-1;i>0;i--)
		{
			int l=getlca(vs[i],vs[i-1]);
			if(l)vs.pb(l);
		}
		sort(vs.begin(),vs.end());vs.erase(unique(vs.begin(),vs.end()),vs.end());
		for(auto&x:vs)x=seq[x];
//		printf("extract ");for(auto x:vs)printf("%d ",x);puts("");

		vector<pii> ret;
		for(auto x:vs)
		{
			while(top&&edfn[stk[top]]<dfn[x])top--;
			if(top)ret.pb(mp(stk[top],x));
			stk[++top]=x;
		}
//		for(auto e : ret)printf("edge %d %d\n",e.ff,e.ss);
		return ret;
	}
};

struct graph
{
	int nxt[maxn<<2],to[maxn<<2],head[maxn],etot;
	bool bridge[maxn<<1];
	void addedge(int u,int v)
	{
		if(u==v)return;
//		printf("Edge %d %d\n",u,v);
		nxt[++etot]=head[u];head[u]=etot;to[etot]=v;
		nxt[++etot]=head[v];head[v]=etot;to[etot]=u;
	}

	void clear(int n)
	{
		for(int i=1;i<=n;i++)head[i]=0;
		etot=1;
	}

	int dfn[maxn],low[maxn],timer,bcc[maxn],btot;
	int stk[maxn],top;
	void dfs(int x,int fid)
	{
		dfn[x]=low[x]=++timer;
		stk[++top]=x;
		for(int i=head[x];i;i=nxt[i])if(i!=fid)
		{
			if(!dfn[to[i]])
			{
				dfs(to[i],i^1);
				low[x]=min(low[x],low[to[i]]);
			}
			else low[x]=min(low[x],dfn[to[i]]);
		}
		if(low[x]==dfn[x])
		{
			btot++;
			while(true)
			{
				bcc[stk[top]]=btot;
				if(stk[top--]==x)break;
			}
			if(fid)bridge[fid>>1]=1;
		}
	}
	void shrink(int n)
	{
		timer=btot=0;
		for(int i=1;i<=n;i++)dfn[i]=0;
		for(int i=1;i<=(etot)>>1;i++)bridge[i]=0;
		for(int i=1;i<=n;i++)if(!dfn[i])dfs(i,0);
//		printf("bcc ");for(int i=1;i<=n;i++)printf("%d ",bcc[i]);
//		puts("");
	}
	void construct_tree(tree&T)
	{
		for(int i=1;i<=(etot)>>1;i++)if(bridge[i])
		{
			int u=to[i<<1],v=to[i<<1|1];
			T.addedge(bcc[u],bcc[v]);
		}
		T.prework(btot);
	}
};

graph G1,G2;
tree T;
int id[maxn];
int va[maxn],eu[maxn],ev[maxn];

int main()
{
	scanf("%d%d%d",&n,&m,&q);
	G1.clear(n);
	for(int i=1,u,v;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		G1.addedge(u,v);
	}
	G1.shrink(n);
	G1.construct_tree(T);

//	for(int i=1;i<=n;i++)printf("i= %d bcc= %d\n",i,G1.bcc[i]);

	int R=n-1;
	for(int qq=1;qq<=q;qq++)
	{
		int N,M;
		scanf("%d%d",&N,&M);
		vector<int> vs;
		for(int i=1;i<=N;i++)
		{
			scanf("%d",va+i);
			va[i]=(va[i]+R)%n+1;
			vs.pb(G1.bcc[va[i]]);
		}
		for(int i=1;i<=M;i++)
		{
			scanf("%d%d",eu+i,ev+i);
			eu[i]=(eu[i]+R)%n+1;
			ev[i]=(ev[i]+R)%n+1;
			vs.pb(G1.bcc[eu[i]]);
			vs.pb(G1.bcc[ev[i]]);
		}

		sort(vs.begin(),vs.end());vs.erase(unique(vs.begin(),vs.end()),vs.end());
		vector<pii> es=T.extract(vs);

		int sz=(int)vs.size();
		for(int i=0;i<sz;i++)id[vs[i]]=i+1;
		G2.clear(sz);
		for(auto e:es)G2.addedge(id[e.ff],id[e.ss]);
		for(int i=1;i<=M;i++)G2.addedge(id[G1.bcc[eu[i]]],id[G1.bcc[ev[i]]]);

		G2.shrink(sz);
		bool ok=1;int piv=G2.bcc[id[G1.bcc[va[1]]]];
		for(int i=2;i<=N&&ok;i++)ok&=(G2.bcc[id[G1.bcc[va[i]]]]==piv);
		if(ok)
		{
			puts("YES");
			R=(R+qq)%n;
		}
		else puts("NO");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int maxn=300111;
int n,m,q;

struct tree
{
	int nxt[maxn<<1],to[maxn<<1],head[maxn],etot;
	int fa[20][maxn],dep[maxn],dfn[maxn],timer,seq[maxn],edfn[maxn];

	tree()
	{
		memset(head,0,sizeof(head));
		etot=1;
	}

	void addedge(int u,int v)
	{
		if(u==v)return;
//		printf("%d %d\n",u,v);
		nxt[++etot]=head[u];head[u]=etot;
		to[etot]=v;
		nxt[++etot]=head[v];head[v]=etot;
		to[etot]=u;
	}

	void dfs(int x,int f,int d)
	{
		dfn[x]=++timer;seq[timer]=x;fa[0][timer]=dfn[f];dep[timer]=d;
		for(int i=1;i<20;i++)fa[i][timer]=fa[i-1][fa[i-1][timer]];

		for(int i=head[x];i;i=nxt[i])if(to[i]!=f)
			dfs(to[i],x,d+1);
		edfn[x]=timer;
	}

	int getlca(int u,int v)//x -> dfn[x]
	{
		if(dep[u]<dep[v])swap(u,v);
		for(int i=19;i>=0;i--)if(dep[u]-dep[v]>>i)u=fa[i][u];
		if(u==v)return u;
		for(int i=19;i>=0;i--)if(fa[i][u]!=fa[i][v])
		{
			u=fa[i][u];
			v=fa[i][v];
		}
		return fa[0][u];
	}

	void prework(int n)
	{
		timer=0;
		for(int i=1;i<=n;i++)if(!dfn[i])
			dfs(i,0,1);
//		printf("dep ");for(int i=1;i<=n;i++)printf("%d ",dep[dfn[i]]);puts("");
	}

	int stk[maxn],top;
	vector<pii> extract(vi&vs)
	{
		for(auto&x:vs)x=dfn[x];
		sort(vs.begin(),vs.end());
		for(int i=vs.size()-1;i>0;i--)
		{
			int l=getlca(vs[i],vs[i-1]);
//			printf("vs %d %d l= %d\n",seq[vs[i]],seq[vs[i-1]],seq[l]);
			if(l)vs.pb(l);
		}
		sort(vs.begin(),vs.end());vs.erase(unique(vs.begin(),vs.end()),vs.end());
		for(auto&x:vs)x=seq[x];
//		printf("extract ");for(auto x:vs)printf("%d ",x);puts("");

		top=0;
		vector<pii> ret;
		for(auto x:vs)
		{
			while(top&&edfn[stk[top]]<dfn[x])top--;
			if(top)ret.pb(mp(stk[top],x));
			stk[++top]=x;
		}
//		for(auto e : ret)printf("edge %d %d\n",e.ff,e.ss);
		return ret;
	}
};

struct graph
{
	int nxt[maxn<<2],to[maxn<<2],head[maxn],etot;
	bool bridge[maxn<<1];
	void addedge(int u,int v)
	{
		if(u==v)return;
//		printf("Edge %d %d\n",u,v);
		nxt[++etot]=head[u];head[u]=etot;to[etot]=v;
		nxt[++etot]=head[v];head[v]=etot;to[etot]=u;
	}

	void clear(int n)
	{
		for(int i=1;i<=n;i++)head[i]=0;
		etot=1;
	}

	int dfn[maxn],low[maxn],timer,bcc[maxn],btot;
	int stk[maxn],top;
	void dfs(int x,int fid)
	{
		dfn[x]=low[x]=++timer;
		stk[++top]=x;
		for(int i=head[x];i;i=nxt[i])if(i!=fid)
		{
			if(!dfn[to[i]])
			{
				dfs(to[i],i^1);
				low[x]=min(low[x],low[to[i]]);
			}
			else low[x]=min(low[x],dfn[to[i]]);
		}
		if(low[x]==dfn[x])
		{
			btot++;
			while(true)
			{
				bcc[stk[top]]=btot;
				if(stk[top--]==x)break;
			}
			if(fid)bridge[fid>>1]=1;
		}
	}
	void shrink(int n)
	{
		timer=btot=0;
		for(int i=1;i<=n;i++)dfn[i]=0;
		for(int i=1;i<=(etot)>>1;i++)bridge[i]=0;
		for(int i=1;i<=n;i++)if(!dfn[i])dfs(i,0);
//		printf("bcc ");for(int i=1;i<=n;i++)printf("%d ",bcc[i]);
//		puts("");
	}
	void construct_tree(tree&T)
	{
		for(int i=1;i<=(etot)>>1;i++)if(bridge[i])
		{
			int u=to[i<<1],v=to[i<<1|1];
			T.addedge(bcc[u],bcc[v]);
		}
		T.prework(btot);
	}
};

graph G1,G2;
tree T;
int id[maxn];
int va[maxn],eu[maxn],ev[maxn];

int main()
{
	scanf("%d%d%d",&n,&m,&q);
	G1.clear(n);
	for(int i=1,u,v;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		G1.addedge(u,v);
	}
	G1.shrink(n);
//	puts("tree");
	G1.construct_tree(T);

//	for(int i=1;i<=n;i++)printf("i= %d bcc= %d\n",i,G1.bcc[i]);

	int R=n-1;
	for(int qq=1;qq<=q;qq++)
	{
		int N,M;
		scanf("%d%d",&N,&M);
		vector<int> vs;
		for(int i=1;i<=N;i++)
		{
			scanf("%d",va+i);
			va[i]=(va[i]+R)%n+1;
			vs.pb(G1.bcc[va[i]]);
		}
		for(int i=1;i<=M;i++)
		{
			scanf("%d%d",eu+i,ev+i);
			eu[i]=(eu[i]+R)%n+1;
			ev[i]=(ev[i]+R)%n+1;
			vs.pb(G1.bcc[eu[i]]);
			vs.pb(G1.bcc[ev[i]]);
		}

		sort(vs.begin(),vs.end());vs.erase(unique(vs.begin(),vs.end()),vs.end());
		vector<pii> es=T.extract(vs);
//		printf("vs ");for(auto x:vs)printf("%d ",n+1-x);puts("");

		int sz=(int)vs.size();
		for(int i=0;i<sz;i++)id[vs[i]]=i+1;
		G2.clear(sz);
		for(auto e:es)
		{
//			printf("Edge %d %d\n",e.ff,e.ss);
			G2.addedge(id[e.ff],id[e.ss]);
		}
		for(int i=1;i<=M;i++)G2.addedge(id[G1.bcc[eu[i]]],id[G1.bcc[ev[i]]]);

		G2.shrink(sz);
		bool ok=1;int piv=G2.bcc[id[G1.bcc[va[1]]]];
		for(int i=2;i<=N&&ok;i++)ok&=(G2.bcc[id[G1.bcc[va[i]]]]==piv);
		if(ok)
		{
			puts("YES");
			R=(R+qq)%n;
		}
		else puts("NO");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int maxn=300111;
int n,m,q;

struct tree
{
	int nxt[maxn<<1],to[maxn<<1],head[maxn],etot;
	int fa[20][maxn],dep[maxn],dfn[maxn],timer,seq[maxn],edfn[maxn];

	tree()
	{
		memset(head,0,sizeof(head));
		etot=1;
	}

	void addedge(int u,int v)
	{
		if(u==v)return;
		nxt[++etot]=head[u];head[u]=etot;
		to[etot]=v;
		nxt[++etot]=head[v];head[v]=etot;
		to[etot]=u;
	}

	void dfs(int x,int f,int d)
	{
		dfn[x]=++timer;seq[timer]=x;fa[0][timer]=f;dep[timer]=d;
		for(int i=1;i<20;i++)fa[i][timer]=fa[i-1][fa[i-1][timer]];

		for(int i=head[x];i;i=nxt[i])if(to[i]!=f)
			dfs(to[i],x,d+1);
		edfn[x]=timer;
	}

	int getlca(int u,int v)//x -> dfn[x]
	{
		if(dep[u]<dep[v])swap(u,v);
		for(int i=19;i>=0;i--)if(dep[u]-dep[v]>>i)u=fa[i][u];
		if(u==v)return u;
		for(int i=19;i>=0;i--)if(fa[i][u]!=fa[i][v])
		{
			u=fa[i][u];
			v=fa[i][v];
		}
		return fa[0][u];
	}

	void prework(int n)
	{
		timer=0;
		for(int i=1;i<=n;i++)if(!dfn[i])
			dfs(i,0,1);
	}

	int stk[maxn],top;
	vector<pii> extract(vi&vs)
	{
		for(auto&x:vs)x=dfn[x];
		sort(vs.begin(),vs.end());
		for(int i=vs.size()-1;i>0;i--)
		{
			int l=getlca(vs[i],vs[i-1]);
			if(l)vs.pb(l);
		}
		sort(vs.begin(),vs.end());vs.erase(unique(vs.begin(),vs.end()),vs.end());
		for(auto&x:vs)x=seq[x];
//		printf("extract ");for(auto x:vs)printf("%d ",x);puts("");

		top=0;
		vector<pii> ret;
		for(auto x:vs)
		{
			while(top&&edfn[stk[top]]<dfn[x])top--;
			if(top)ret.pb(mp(stk[top],x));
			stk[++top]=x;
		}
//		for(auto e : ret)printf("edge %d %d\n",e.ff,e.ss);
		return ret;
	}
};

struct graph
{
	int nxt[maxn<<2],to[maxn<<2],head[maxn],etot;
	bool bridge[maxn<<1];
	void addedge(int u,int v)
	{
		if(u==v)return;
//		printf("Edge %d %d\n",u,v);
		nxt[++etot]=head[u];head[u]=etot;to[etot]=v;
		nxt[++etot]=head[v];head[v]=etot;to[etot]=u;
	}

	void clear(int n)
	{
		for(int i=1;i<=n;i++)head[i]=0;
		etot=1;
	}

	int dfn[maxn],low[maxn],timer,bcc[maxn],btot;
	int stk[maxn],top;
	void dfs(int x,int fid)
	{
		dfn[x]=low[x]=++timer;
		stk[++top]=x;
		for(int i=head[x];i;i=nxt[i])if(i!=fid)
		{
			if(!dfn[to[i]])
			{
				dfs(to[i],i^1);
				low[x]=min(low[x],low[to[i]]);
			}
			else low[x]=min(low[x],dfn[to[i]]);
		}
		if(low[x]==dfn[x])
		{
			btot++;
			while(true)
			{
				bcc[stk[top]]=btot;
				if(stk[top--]==x)break;
			}
			if(fid)bridge[fid>>1]=1;
		}
	}
	void shrink(int n)
	{
		timer=btot=0;
		for(int i=1;i<=n;i++)dfn[i]=0;
		for(int i=1;i<=(etot)>>1;i++)bridge[i]=0;
		for(int i=1;i<=n;i++)if(!dfn[i])dfs(i,0);
//		printf("bcc ");for(int i=1;i<=n;i++)printf("%d ",bcc[i]);
//		puts("");
	}
	void construct_tree(tree&T)
	{
		for(int i=1;i<=(etot)>>1;i++)if(bridge[i])
		{
			int u=to[i<<1],v=to[i<<1|1];
			T.addedge(bcc[u],bcc[v]);
		}
		T.prework(btot);
	}
};

graph G1,G2;
tree T;
int id[maxn];
int va[maxn],eu[maxn],ev[maxn];

int main()
{
	scanf("%d%d%d",&n,&m,&q);
	G1.clear(n);
	for(int i=1,u,v;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		G1.addedge(u,v);
	}
	G1.shrink(n);
	G1.construct_tree(T);

//	for(int i=1;i<=n;i++)printf("i= %d bcc= %d\n",i,G1.bcc[i]);

	int R=n-1;
	for(int qq=1;qq<=q;qq++)
	{
		int N,M;
		scanf("%d%d",&N,&M);
		vector<int> vs;
		for(int i=1;i<=N;i++)
		{
			scanf("%d",va+i);
			va[i]=(va[i]+R)%n+1;
			vs.pb(G1.bcc[va[i]]);
		}
		for(int i=1;i<=M;i++)
		{
			scanf("%d%d",eu+i,ev+i);
			eu[i]=(eu[i]+R)%n+1;
			ev[i]=(ev[i]+R)%n+1;
			vs.pb(G1.bcc[eu[i]]);
			vs.pb(G1.bcc[ev[i]]);
		}

		sort(vs.begin(),vs.end());vs.erase(unique(vs.begin(),vs.end()),vs.end());
//		printf("vs ");for(auto x:vs)printf("%d ",x);puts("");
		vector<pii> es=T.extract(vs);

		int sz=(int)vs.size();
		for(int i=0;i<sz;i++)id[vs[i]]=i+1;
		G2.clear(sz);
		for(auto e:es)
		{
//			printf("Edge %d %d\n",e.ff,e.ss);
			G2.addedge(id[e.ff],id[e.ss]);
		}
		for(int i=1;i<=M;i++)G2.addedge(id[G1.bcc[eu[i]]],id[G1.bcc[ev[i]]]);

		G2.shrink(sz);
		bool ok=1;int piv=G2.bcc[id[G1.bcc[va[1]]]];
		for(int i=2;i<=N&&ok;i++)ok&=(G2.bcc[id[G1.bcc[va[i]]]]==piv);
		if(ok)
		{
			puts("YES");
			R=(R+qq)%n;
		}
		else puts("NO");
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl

#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)
#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)

#define type(x) __typeof(x.begin())

#define orta (bas + son >> 1)
#define sag (k + k + 1)
#define sol (k + k)

#define pb push_back
#define mp make_pair

#define nd second
#define st first

#define endl '\n'

typedef pair < int ,int > pii;

typedef long long ll;

const long long linf = 1e18+5;
int mod = (int) 1e9 + 7;
const int logN = 18;
const int inf = 1e9;
const int N = 1e3 + 5;
const int K = 10;

int bel[N], go[N], q, n, m, x, y, start[N], finish[N], lca[N][logN + 1], T, S, depth[N], e[N][2], SIZE;
vector< int > v[N];

class graph {
    public:
    int n, T, S, es;
    vector< vector< int > > g;
    vector< vector< pii > > v;
    vector< int > bel, ss, start, low;
    graph(int size) {
        n = size;
        es = T = S = 0;
        v.resize(n + 2);
        g.resize(n + 2);
        bel.resize(n + 2, 0);
        low.resize(n + 2, 0);
        start.resize(n + 2, 0);
        ss.clear();
    }

    void clear(int size) {
        n = size;
        T = S = 0;
        es = 0;
        v.clear();
        g.clear();
        v.resize(n + 2);
        g.resize(n + 2);
        bel.resize(n + 2, 0);
        low.resize(n + 2, 0);
        start.resize(n + 2, 0);
        ss.clear();
    }

    void add_edge(int x, int y) {
        ++es;
        v[x].pb(mp(y, es));
        v[y].pb(mp(x, es));
    }

    void dfs(int node, int root) {
        start[node] = low[node] = ++T;
        ss.pb(node);
        foreach(it, v[node]) {
            if(it->nd == root) continue;
            if(start[it->st])
                low[node] = min(low[node], start[it->st]);
            else {
                dfs(it->st, it->nd);
                low[node] = min(low[node], low[it->st]);
            }
        }
        if(low[node] == start[node]) {
            bel[node] = ++S;
            while(ss.back() != node) {
                bel[ss.back()] = S;
                ss.pop_back();
            } ss.pop_back();
        }
    }

    void doit() {
        FOR(i, 1, n)
            if(!low[i]) {
                dfs(i, 0);
            }
        FOR(i, 1, n) {
            foreach(it, v[i])
                if(bel[i] != bel[it->st]) {
                    g[bel[i]].pb(bel[it->st]);
                }
        }
    }

};

void rotate(int &x, int y) {
    x += y; x %= SIZE;
    if(x == 0) x = SIZE;
}

int LCA(int x, int y) {
    if(depth[x] < depth[y]) swap(x, y);
    int diff = depth[x] - depth[y];
    FOR(i, 0, logN)
        if((1 << i) & diff)
            x = lca[x][i];
    if(x == y) return x;
    ROF(i, logN, 0)
        if(lca[x][i] != lca[y][i])
            x = lca[x][i],
            y = lca[y][i];
    return lca[x][0];
}

int dfs(int node, int root) {
    lca[node][0] = root;
    start[node] = ++T;
    depth[node] = depth[root] + 1;
    foreach(it, v[node])
        if(*it != root)
            dfs(*it, node);
    finish[node] = T;
}

bool cmp(int x, int y) { return start[x] < start[y]; }

int main() {
    scanf("%d %d %d", &n, &m, &q);
    SIZE = n;
    graph A(n), B(0);
    FOR(i, 1, m) {
        scanf("%d %d", &x, &y);
        A.add_edge(x, y);
    } A.doit();
    int SZ = A.S;
    FOR(i, 1, SZ) v[i] = A.g[i];
    FOR(i, 1, n) bel[i] = A.bel[i];
    dfs(1, 0);
    FOR(j, 1, logN)
        FOR(i, 1, SZ)
            lca[i][j] = lca[lca[i][j - 1]][j - 1];
    int last = 0;
    vector< int > good, all;
    FOR(qq, 1, q) {
        scanf("%d %d", &n, &m);
        good.clear();
        all.clear();
        FOR(i, 1, n) {
            scanf("%d", &x);
            rotate(x, last);
            x = bel[x];
            good.pb(x);
            all.pb(x);
        }
        FOR(i, 1, m) {
            scanf("%d %d", &e[i][0], &e[i][1]);
            rotate(e[i][0], last);
            rotate(e[i][1], last);
            e[i][0] = bel[e[i][0]];
            e[i][1] = bel[e[i][1]];
            all.pb(e[i][0]);
            all.pb(e[i][1]);
        }
        int t = all.size();
        sort(all.begin(), all.end(), cmp);
        for(int i = 1; i < t; i++)
            if(all[i-1] != all[i]) {
                int l = LCA(all[i - 1], all[i]);
                if(l) all.pb(l);

            }
        vector< int > S;
        sort(all.begin(), all.end(), cmp);
        all.resize(unique(all.begin(), all.end()) - all.begin());
        for(int i = 0; i < all.size(); i++) {
            go[all[i]] = i + 1;
        }
        graph B(all.size());
        S.pb(all[0]);
        for(int i = 1; i < all.size(); i++) {
            while(S.size() && finish[S.back()] < start[all[i]]) S.pop_back();
            if(S.size()) {
                B.add_edge(go[S.back()], go[all[i]]);
            }
            S.pb(all[i]);
        }
        FOR(i, 1, m) {
            B.add_edge(go[e[i][0]], go[e[i][1]]);
        }
        B.doit();
        int flag = true, belong = B.bel[go[good[0]]];
        for(int i = 1; i < good.size(); i++)
            if(belong != B.bel[go[good[i]]])
                flag = false;
        last += flag * qq;
        if(flag == false)
            printf("NO\n");
        else
            printf("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 2

*/


#include <bits/stdc++.h>

using namespace std;

#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl

#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)
#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)

#define type(x) __typeof(x.begin())

#define orta (bas + son >> 1)
#define sag (k + k + 1)
#define sol (k + k)

#define pb push_back
#define mp make_pair

#define nd second
#define st first

#define endl '\n'

typedef pair < int ,int > pii;

typedef long long ll;

const long long linf = 1e18+5;
int mod = (int) 1e9 + 7;
const int logN = 18;
const int inf = 1e9;
const int N = 3e5 + 5;
const int K = 10;

int bel[N], go[N], q, n, m, x, y, start[N], finish[N], lca[N][logN + 1], T, S, depth[N], e[N][2], SIZE;
vector< int > v[N];

class graph {
    public:
    int n, T, S, es;
    vector< vector< int > > g;
    vector< vector< pii > > v;
    vector< int > bel, ss, start, low;
    graph(int size) {
        n = size;
        es = T = S = 0;
        v.resize(n + 2);
        g.resize(n + 2);
        bel.resize(n + 2, 0);
        low.resize(n + 2, 0);
        start.resize(n + 2, 0);
        ss.clear();
    }

    void clear(int size) {
        n = size;
        T = S = 0;
        es = 0;
        v.clear();
        g.clear();
        v.resize(n + 2);
        g.resize(n + 2);
        bel.resize(n + 2, 0);
        low.resize(n + 2, 0);
        start.resize(n + 2, 0);
        ss.clear();
    }

    void add_edge(int x, int y) {
        ++es;
        v[x].pb(mp(y, es));
        v[y].pb(mp(x, es));
    }

    void dfs(int node, int root) {
        start[node] = low[node] = ++T;
        ss.pb(node);
        foreach(it, v[node]) {
            if(it->nd == root) continue;
            if(start[it->st])
                low[node] = min(low[node], start[it->st]);
            else {
                dfs(it->st, it->nd);
                low[node] = min(low[node], low[it->st]);
            }
        }
        if(low[node] == start[node]) {
            bel[node] = ++S;
            while(ss.back() != node) {
                bel[ss.back()] = S;
                ss.pop_back();
            } ss.pop_back();
        }
    }

    void doit() {
        FOR(i, 1, n)
            if(!low[i]) {
                dfs(i, 0);
            }
        FOR(i, 1, n) {
            foreach(it, v[i])
                if(bel[i] != bel[it->st]) {
                    g[bel[i]].pb(bel[it->st]);
                }
        }
    }

};

void rotate(int &x, int y) {
    x += y; x %= SIZE;
    if(x == 0) x = SIZE;
}

int LCA(int x, int y) {
    if(depth[x] < depth[y]) swap(x, y);
    int diff = depth[x] - depth[y];
    FOR(i, 0, logN)
        if((1 << i) & diff)
            x = lca[x][i];
    if(x == y) return x;
    ROF(i, logN, 0)
        if(lca[x][i] != lca[y][i])
            x = lca[x][i],
            y = lca[y][i];
    return lca[x][0];
}

int dfs(int node, int root) {
    lca[node][0] = root;
    start[node] = ++T;
    depth[node] = depth[root] + 1;
    foreach(it, v[node])
        if(*it != root)
            dfs(*it, node);
    finish[node] = T;
}

bool cmp(int x, int y) { return start[x] < start[y]; }

int main() {
    scanf("%d %d %d", &n, &m, &q);
    SIZE = n;
    graph A(n), B(0);
    FOR(i, 1, m) {
        scanf("%d %d", &x, &y);
        A.add_edge(x, y);
    } A.doit();
    int SZ = A.S;
    FOR(i, 1, SZ) v[i] = A.g[i];
    FOR(i, 1, n) bel[i] = A.bel[i];
    FOR(i, 1, SZ) if(lca[i][0] == 0) dfs(i, 0);
    FOR(j, 1, logN)
        FOR(i, 1, SZ)
            lca[i][j] = lca[lca[i][j - 1]][j - 1];
    int last = 0;
    vector< int > good, all;
    FOR(qq, 1, q) {
        last %= SIZE;
        scanf("%d %d", &n, &m);
        good.clear();
        all.clear();
        FOR(i, 1, n) {
            scanf("%d", &x);
            rotate(x, last);
            x = bel[x];
            good.pb(x);
            all.pb(x);
        }
        FOR(i, 1, m) {
            scanf("%d %d", &e[i][0], &e[i][1]);
            rotate(e[i][0], last);
            rotate(e[i][1], last);
            e[i][0] = bel[e[i][0]];
            e[i][1] = bel[e[i][1]];
            all.pb(e[i][0]);
            all.pb(e[i][1]);
        }
        int t = all.size();
        sort(all.begin(), all.end(), cmp);
        for(int i = 1; i < t; i++)
            if(all[i-1] != all[i]) {
                int l = LCA(all[i - 1], all[i]);
                if(l) all.pb(l);

            }
        vector< int > S;
        sort(all.begin(), all.end(), cmp);
        all.resize(unique(all.begin(), all.end()) - all.begin());
        for(int i = 0; i < all.size(); i++) {
            go[all[i]] = i + 1;
        }
        graph B(all.size());
        S.pb(all[0]);
        for(int i = 1; i < all.size(); i++) {
            while(S.size() && finish[S.back()] < start[all[i]]) S.pop_back();
            if(S.size()) {
                B.add_edge(go[S.back()], go[all[i]]);
            }
            S.pb(all[i]);
        }
        FOR(i, 1, m) {
            B.add_edge(go[e[i][0]], go[e[i][1]]);
        }
        B.doit();
        int flag = true, belong = B.bel[go[good[0]]];
        for(int i = 1; i < good.size(); i++)
            if(belong != B.bel[go[good[i]]])
                flag = false;
        last += flag * qq;
        if(flag == false)
            printf("NO\n");
        else
            printf("YES\n");
    }
    return 0;
}

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

*/


#include <bits/stdc++.h>

using namespace std;

#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl

#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)
#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)

#define type(x) __typeof(x.begin())

#define orta (bas + son >> 1)
#define sag (k + k + 1)
#define sol (k + k)

#define pb push_back
#define mp make_pair

#define nd second
#define st first

#define endl '\n'

typedef pair < int ,int > pii;

typedef long long ll;

const long long linf = 1e18+5;
int mod = (int) 1e9 + 7;
const int logN = 18;
const int inf = 1e9;
const int N = 1e3 + 5;
const int K = 10;

int bel[N], go[N], q, n, m, x, y, start[N], finish[N], lca[N][logN + 1], T, S, depth[N], e[N][2], SIZE;
vector< int > v[N];

class graph {
    public:
    int n, T, S, es;
    vector< vector< int > > g;
    vector< vector< pii > > v;
    vector< int > bel, ss, start, low;
    graph(int size) {
        n = size;
        es = T = S = 0;
        v.resize(n + 2);
        g.resize(n + 2);
        bel.resize(n + 2, 0);
        low.resize(n + 2, 0);
        start.resize(n + 2, 0);
        ss.clear();
    }

    void clear(int size) {
        n = size;
        T = S = 0;
        es = 0;
        v.clear();
        g.clear();
        v.resize(n + 2);
        g.resize(n + 2);
        bel.resize(n + 2, 0);
        low.resize(n + 2, 0);
        start.resize(n + 2, 0);
        ss.clear();
    }

    void add_edge(int x, int y) {
        ++es;
        v[x].pb(mp(y, es));
        v[y].pb(mp(x, es));
    }

    void dfs(int node, int root) {
        start[node] = low[node] = ++T;
        ss.pb(node);
        foreach(it, v[node]) {
            if(it->nd == root) continue;
            if(start[it->st])
                low[node] = min(low[node], start[it->st]);
            else {
                dfs(it->st, it->nd);
                low[node] = min(low[node], low[it->st]);
            }
        }
        if(low[node] == start[node]) {
            bel[node] = ++S;
            while(ss.back() != node) {
                bel[ss.back()] = S;
                ss.pop_back();
            } ss.pop_back();
        }
    }

    void doit() {
        FOR(i, 1, n)
            if(!low[i]) {
                dfs(i, 0);
            }
        FOR(i, 1, n) {
            foreach(it, v[i])
                if(bel[i] != bel[it->st]) {
                    g[bel[i]].pb(bel[it->st]);
                }
        }
    }

};

void rotate(int &x, int y) {
    x += y; x %= SIZE;
    if(x == 0) x = SIZE;
}

int LCA(int x, int y) {
    if(depth[x] < depth[y]) swap(x, y);
    int diff = depth[x] - depth[y];
    FOR(i, 0, logN)
        if((1 << i) & diff)
            x = lca[x][i];
    if(x == y) return x;
    ROF(i, logN, 0)
        if(lca[x][i] != lca[y][i])
            x = lca[x][i],
            y = lca[y][i];
    return lca[x][0];
}

int dfs(int node, int root) {
    lca[node][0] = root;
    start[node] = ++T;
    depth[node] = depth[root] + 1;
    foreach(it, v[node])
        if(*it != root)
            dfs(*it, node);
    finish[node] = T;
}

bool cmp(int x, int y) { return start[x] < start[y]; }

int main() {
    scanf("%d %d %d", &n, &m, &q);
    SIZE = n;
    graph A(n), B(0);
    FOR(i, 1, m) {
        scanf("%d %d", &x, &y);
        A.add_edge(x, y);
    } A.doit();
    int SZ = A.S;
    FOR(i, 1, SZ) v[i] = A.g[i];
    FOR(i, 1, n) bel[i] = A.bel[i];
    FOR(i, 1, SZ) if(lca[i][0] == 0) dfs(i, 0);
    FOR(j, 1, logN)
        FOR(i, 1, SZ)
            lca[i][j] = lca[lca[i][j - 1]][j - 1];
    int last = 0;
    vector< int > good, all;
    FOR(qq, 1, q) {
        last %= SIZE;
        scanf("%d %d", &n, &m);
        good.clear();
        all.clear();
        FOR(i, 1, n) {
            scanf("%d", &x);
            rotate(x, last);
            x = bel[x];
            good.pb(x);
            all.pb(x);
        }
        FOR(i, 1, m) {
            scanf("%d %d", &e[i][0], &e[i][1]);
            rotate(e[i][0], last);
            rotate(e[i][1], last);
            e[i][0] = bel[e[i][0]];
            e[i][1] = bel[e[i][1]];
            all.pb(e[i][0]);
            all.pb(e[i][1]);
        }
        int t = all.size();
        sort(all.begin(), all.end(), cmp);
        for(int i = 1; i < t; i++)
            if(all[i-1] != all[i]) {
                int l = LCA(all[i - 1], all[i]);
                if(l) all.pb(l);

            }
        vector< int > S;
        sort(all.begin(), all.end(), cmp);
        all.resize(unique(all.begin(), all.end()) - all.begin());
        for(int i = 0; i < all.size(); i++) {
            go[all[i]] = i + 1;
        }
        graph B(all.size());
        S.pb(all[0]);
        for(int i = 1; i < all.size(); i++) {
            while(S.size() && finish[S.back()] < start[all[i]]) S.pop_back();
            if(S.size()) {
                B.add_edge(go[S.back()], go[all[i]]);
            }
            S.pb(all[i]);
        }
        FOR(i, 1, m) {
            B.add_edge(go[e[i][0]], go[e[i][1]]);
        }
        B.doit();
        int flag = true, belong = B.bel[go[good[0]]];
        for(int i = 1; i < good.size(); i++)
            if(belong != B.bel[go[good[i]]])
                flag = false;
        last += flag * qq;
        if(flag == false)
            printf("NO\n");
        else
            printf("YES\n");
    }
    return 0;
}

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

*/


#include <bits/stdc++.h>

using namespace std;

#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl

#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)
#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)

#define type(x) __typeof(x.begin())

#define orta (bas + son >> 1)
#define sag (k + k + 1)
#define sol (k + k)

#define pb push_back
#define mp make_pair

#define nd second
#define st first

#define endl '\n'

typedef pair < int ,int > pii;

typedef long long ll;

const long long linf = 1e18+5;
int mod = (int) 1e9 + 7;
const int logN = 18;
const int inf = 1e9;
const int N = 1e3 + 5;
const int K = 10;

int bel[N], go[N], q, n, m, x, y, start[N], finish[N], lca[N][logN + 1], T, S, depth[N], e[N][2], SIZE;
vector< int > v[N];

class graph {
    public:
    int n, T, S, es;
    vector< vector< int > > g;
    vector< vector< pii > > v;
    vector< int > bel, ss, start, low;
    graph(int size) {
        n = size;
        es = T = S = 0;
        v.resize(n + 2);
        g.resize(n + 2);
        bel.resize(n + 2, 0);
        low.resize(n + 2, 0);
        start.resize(n + 2, 0);
        ss.clear();
    }

    void clear(int size) {
        n = size;
        T = S = 0;
        es = 0;
        v.clear();
        g.clear();
        v.resize(n + 2);
        g.resize(n + 2);
        bel.resize(n + 2, 0);
        low.resize(n + 2, 0);
        start.resize(n + 2, 0);
        ss.clear();
    }

    void add_edge(int x, int y) {
        ++es;
        v[x].pb(mp(y, es));
        v[y].pb(mp(x, es));
    }

    void dfs(int node, int root) {
        start[node] = low[node] = ++T;
        ss.pb(node);
        foreach(it, v[node]) {
            if(it->nd == root) continue;
            if(start[it->st])
                low[node] = min(low[node], start[it->st]);
            else {
                dfs(it->st, it->nd);
                low[node] = min(low[node], low[it->st]);
            }
        }
        if(low[node] == start[node]) {
            bel[node] = ++S;
            while(ss.back() != node) {
                bel[ss.back()] = S;
                ss.pop_back();
            } ss.pop_back();
        }
    }

    void doit() {
        FOR(i, 1, n)
            if(!low[i]) {
                dfs(i, 0);
            }
        FOR(i, 1, n) {
            foreach(it, v[i])
                if(bel[i] != bel[it->st]) {
                    g[bel[i]].pb(bel[it->st]);
                }
        }
    }

};

void rotate(int &x, int y) {
    x += y; x %= SIZE;
    if(x == 0) x = SIZE;
}

int LCA(int x, int y) {
    if(depth[x] < depth[y]) swap(x, y);
    int diff = depth[x] - depth[y];
    FOR(i, 0, logN)
        if((1 << i) & diff)
            x = lca[x][i];
    if(x == y) return x;
    ROF(i, logN, 0)
        if(lca[x][i] != lca[y][i])
            x = lca[x][i],
            y = lca[y][i];
    return lca[x][0];
}

int dfs(int node, int root) {
    lca[node][0] = root;
    start[node] = ++T;
    depth[node] = depth[root] + 1;
    foreach(it, v[node])
        if(*it != root)
            dfs(*it, node);
    finish[node] = T;
}

bool cmp(int x, int y) { return start[x] < start[y]; }

int main() {
    scanf("%d %d %d", &n, &m, &q);
    SIZE = n;
    graph A(n), B(0);
    FOR(i, 1, m) {
        scanf("%d %d", &x, &y);
        A.add_edge(x, y);
    } A.doit();
    int SZ = A.S;
    FOR(i, 1, SZ) v[i] = A.g[i];
    FOR(i, 1, n) bel[i] = A.bel[i];
    dfs(1, 0);
    FOR(j, 1, logN)
        FOR(i, 1, SZ)
            lca[i][j] = lca[lca[i][j - 1]][j - 1];
    int last = 0;
    vector< int > good, all;
    FOR(qq, 1, q) {
        scanf("%d %d", &n, &m);
        good.clear();
        all.clear();
        FOR(i, 1, n) {
            scanf("%d", &x);
            rotate(x, last);
            x = bel[x];
            good.pb(x);
            all.pb(x);
        }
        FOR(i, 1, m) {
            scanf("%d %d", &e[i][0], &e[i][1]);
            rotate(e[i][0], last);
            rotate(e[i][1], last);
            e[i][0] = bel[e[i][0]];
            e[i][1] = bel[e[i][1]];
            all.pb(e[i][0]);
            all.pb(e[i][1]);
        }
        int t = all.size();
        sort(all.begin(), all.end(), cmp);
        for(int i = 1; i < t; i++)
            if(all[i-1] != all[i]) {
                int l = LCA(all[i - 1], all[i]);
                if(l) all.pb(l);

            }
        vector< int > S;
        sort(all.begin(), all.end(), cmp);
        all.resize(unique(all.begin(), all.end()) - all.begin());
        for(int i = 0; i < all.size(); i++) {
            go[all[i]] = i + 1;
        }
        graph B(all.size());
        S.pb(all[0]);
        for(int i = 1; i < all.size(); i++) {
            while(S.size() && finish[S.back()] < start[all[i]]) S.pop_back();
            if(S.size()) {
                B.add_edge(go[S.back()], go[all[i]]);
            }
            S.pb(all[i]);
        }
        FOR(i, 1, m) {
            B.add_edge(go[e[i][0]], go[e[i][1]]);
        }
        B.doit();
        int flag = true, belong = B.bel[go[good[0]]];
        for(int i = 1; i < good.size(); i++)
            if(belong != B.bel[go[good[i]]])
                flag = false;
        last += flag;
        if(flag == false)
            printf("NO\n");
        else
            printf("YES\n");
    }
    return 0;
}

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


#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 300005, M = 300005, LOGN = 21;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}

template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x +'0');
	else write(x / 10), putchar(x % 10 + '0');
}

struct edge {
	int to, nxt;
} ;
struct graph {
	int V, head[N], cnt;
	edge g[M << 1];
	void init (int v) {
		V = v;
		for (int i = 0; i < v; i++) head[i] = -1;
		cnt = 0;
	}

	void addedge (int u, int v) {
		edge e = {v, head[u]};
		g[head[u] = cnt++] = e;
	}

	int low[N], dfn[N], bcc[N], tot, t;
	stack<int> stk;

	void dfs (int u, int fa) {
		low[u] = dfn[u] = ++tot;
		stk.push(u);
		for (int i = head[u]; ~i; i = g[i].nxt) {
			int v = g[i].to;
			if (i != fa) {
				if (!dfn[v]) dfs(v, i ^ 1), low[u] = min(low[u], low[v]);
				else low[u] = min(low[u], dfn[v]);
			}
		}

		if (low[u] == dfn[u]) {
			for (; ;) {
				int x = stk.top();
				bcc[x] = t, stk.pop();
				if (x == u) break;
			}
			t++;
		}
	}
	void get_bcc () {
		tot = t = 0;
		for (int i = 0; i < V; i++) low[i] = dfn[i] = 0;
		for (int i = 0; i < V; i++) {
			if (!dfn[i]) dfs(i, -1);
		}
	}
} g1, tree, g2;

int dep[N], euler[N << 1][LOGN], id[N], Log2[N << 1], cnt = 0;
void dfs (int u, int fa) {
	euler[id[u] = ++cnt][0] = u;
	for (int i = tree.head[u]; ~i; i = tree.g[i].nxt) {
		int v = tree.g[i].to;
		if (v != fa) {
			dep[v] = dep[u] + 1;
			dfs(v, u);
			euler[++cnt][0] = u;
		}
	}
}

void rmq_init () {
	for (int i = 1; i <= cnt; i++) {
		for (int j = 1; (1 << j) <= i; j++) {
			if (dep[euler[i][j - 1]] < dep[euler[i - (1 << (j - 1))][j - 1]]) euler[i][j] = euler[i][j - 1];
			else euler[i][j] = euler[i - (1 << (j - 1))][j - 1];
		}
	}
	Log2[1] = 0;
	for (int i = 2; i <= cnt; i++) Log2[i] = Log2[i >> 1] + 1;
}

int lca (int u, int v) {
	int l = id[u], r = id[v];
	if (l > r) swap(l, r);
	int label = Log2[r - l + 1];
	if (dep[euler[r][label]] < dep[euler[l + (1 << label) - 1][label]]) return euler[r][label];
	return euler[l + (1 << label) - 1][label];
}

int n, m, q, stk[N], R = 0, top = 0;
vector<int> vec, vec_v;
vector<pair<int, int> > vec_e;

bool cmp (int x, int y) {
	return id[x] < id[y];
}
int main () {
	read(n), read(m), read(q);
	g1.init(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		read(u), read(v);
		u--, v--;
		g1.addedge(u, v), g1.addedge(v, u);
	}

	g1.get_bcc();
	tree.init(g1.t + 1);
	for (int i = 0; i < n; i++) {
		for (int j = g1.head[i]; ~j; j = g1.g[j].nxt) {
			int u = i, v = g1.g[j].to;
			if (g1.bcc[u] != g1.bcc[v]) tree.addedge(g1.bcc[u], g1.bcc[v]);
		}
	}

	for (int i = 0; i <= g1.t; i++) dep[i] = 0;
	euler[id[g1.t] = ++cnt][0] = g1.t;
	for (int i = 0; i < g1.t; i++) {
		if (!dep[i]) {
			tree.addedge(g1.t, i), tree.addedge(i, g1.t);
			dep[i] = 1, dfs(i, g1.t);
			euler[++cnt][0] = g1.t;
		}
	}
	rmq_init();

	for (int i = 1; i <= q; i++) {
		vec.clear(), vec_v.clear(), vec_e.clear();
		int V, E;
		read(V), read(E);
		for (int j = 0; j < V; j++) {
			int u;
			read(u);
			u--, u = (u + R) % n;
			vec_v.push_back(g1.bcc[u]), vec.push_back(g1.bcc[u]);
		}
		for (int j = 0; j < E; j++) {
			int u, v;
			read(u), read(v);
			u--, u = (u + R) % n;
			v--, v = (v + R) % n;
			vec_e.push_back(make_pair(g1.bcc[u], g1.bcc[v]));
			vec_v.push_back(g1.bcc[u]), vec_v.push_back(g1.bcc[v]);
		}

		sort(vec_v.begin(), vec_v.end(), cmp);

		stk[top = 0] = g1.t;
		for (int j = 0; j < vec_v.size(); j++) {
			int p = lca(vec_v[j], stk[top]);
			while (top && id[stk[top - 1]] >= id[p]) {
				vec_e.push_back(make_pair(stk[top - 1], stk[top]));
				top--;
			}
			if (p != stk[top]) {
				vec_e.push_back(make_pair(p, stk[top]));
				stk[top] = p;
			}
			if (stk[top] != vec_v[j]) stk[++top] = vec_v[j];
		}

		while (top) {
			vec_e.push_back(make_pair(stk[top - 1], stk[top]));
			top--;
		}

		vec_v.clear();
		for (int j = 0; j < vec_e.size(); j++) {
			vec_v.push_back(vec_e[j].first);
			vec_v.push_back(vec_e[j].second);
		}

		sort(vec_v.begin(), vec_v.end());
		int s = unique(vec_v.begin(), vec_v.end()) - vec_v.begin();
		g2.init(s);

		for (int j = 0; j < vec_e.size(); j++) {
			if (vec_e[j].first == g1.t) continue;
			if (vec_e[j].second == g1.t) continue;
			int u = lower_bound(vec_v.begin(), vec_v.begin() + s, vec_e[j].first) - vec_v.begin();
			int v = lower_bound(vec_v.begin(), vec_v.begin() + s, vec_e[j].second) - vec_v.begin();
			g2.addedge(u, v), g2.addedge(v, u);
		}

		g2.get_bcc();
		bool flag = true;
		for (int j = 1; j < vec.size(); j++) {
			int u = lower_bound(vec_v.begin(), vec_v.begin() + s, vec[j]) - vec_v.begin();
			int v = lower_bound(vec_v.begin(), vec_v.begin() + s, vec[0]) - vec_v.begin();
			if (g2.bcc[u] != g2.bcc[v]) flag = false;
		}
		if (flag) puts("YES"), R = (R + i) % n;
		else puts("NO");
	}
	return 0;
}
//
//


#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 300005, M = 300005, LOGN = 21;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}

template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x +'0');
	else write(x / 10), putchar(x % 10 + '0');
}

struct edge {
	int to, nxt;
} ;
struct graph {
	int V, head[N], cnt;
	edge g[M << 1];
	void init (int v) {
		V = v;
		for (int i = 0; i < v; i++) head[i] = -1;
		cnt = 0;
	}

	void addedge (int u, int v) {
		edge e = {v, head[u]};
		g[head[u] = cnt++] = e;
	}

	int low[N], dfn[N], bcc[N], tot, t;
	stack<int> stk;

	void dfs (int u, int fa) {
		low[u] = dfn[u] = ++tot;
		stk.push(u);
		for (int i = head[u]; ~i; i = g[i].nxt) {
			int v = g[i].to;
			if (i != fa) {
				if (!dfn[v]) dfs(v, i ^ 1), low[u] = min(low[u], low[v]);
				else low[u] = min(low[u], dfn[v]);
			}
		}

		if (low[u] == dfn[u]) {
			for (; ;) {
				int x = stk.top();
				bcc[x] = t, stk.pop();
				if (x == u) break;
			}
			t++;
		}
	}
	void get_bcc () {
		tot = t = 0;
		for (int i = 0; i < V; i++) low[i] = dfn[i] = 0;
		for (int i = 0; i < V; i++) {
			if (!dfn[i]) dfs(i, -1);
		}
	}
} g1, tree, g2;

int dep[N], euler[N << 1][LOGN], id[N], Log2[N << 1], cnt = 0;
void dfs (int u, int fa) {
	euler[id[u] = ++cnt][0] = u;
	for (int i = tree.head[u]; ~i; i = tree.g[i].nxt) {
		int v = tree.g[i].to;
		if (v != fa) {
			dep[v] = dep[u] + 1;
			dfs(v, u);
			euler[++cnt][0] = u;
		}
	}
}

void rmq_init () {
	for (int i = 1; i <= cnt; i++) {
		for (int j = 1; (1 << j) <= i; j++) {
			if (dep[euler[i][j - 1]] < dep[euler[i - (1 << (j - 1))][j - 1]]) euler[i][j] = euler[i][j - 1];
			else euler[i][j] = euler[i - (1 << (j - 1))][j - 1];
		}
	}
	Log2[1] = 0;
	for (int i = 2; i <= cnt; i++) Log2[i] = Log2[i >> 1] + 1;
}

int lca (int u, int v) {
	int l = id[u], r = id[v];
	if (l > r) swap(l, r);
	int label = Log2[r - l + 1];
	if (dep[euler[r][label]] < dep[euler[l + (1 << label) - 1][label]]) return euler[r][label];
	return euler[l + (1 << label) - 1][label];
}

int n, m, q, stk[N], R = 0, top = 0;
vector<int> vec, vec_v;
vector<pair<int, int> > vec_e;

bool cmp (int x, int y) {
	return id[x] < id[y];
}
int main () {
	read(n), read(m), read(q);
	g1.init(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		read(u), read(v);
		u--, v--;
		g1.addedge(u, v), g1.addedge(v, u);
	}

	g1.get_bcc();
	tree.init(g1.t + 1);
	for (int i = 0; i < n; i++) {
		for (int j = g1.head[i]; ~j; j = g1.g[j].nxt) {
			int u = i, v = g1.g[j].to;
			if (g1.bcc[u] != g1.bcc[v]) tree.addedge(g1.bcc[u], g1.bcc[v]);
		}
	}

	for (int i = 0; i <= g1.t; i++) dep[i] = 0;
	euler[id[g1.t] = ++cnt][0] = g1.t;
	for (int i = 0; i < g1.t; i++) {
		if (!dep[i]) {
			tree.addedge(g1.t, i), tree.addedge(i, g1.t);
			dep[i] = 1, dfs(i, g1.t);
			euler[++cnt][0] = g1.t;
		}
	}
	rmq_init();

	for (int i = 1; i <= q; i++) {
		vec.clear(), vec_v.clear(), vec_e.clear();
		int V, E;
		read(V), read(E);
		for (int j = 0; j < V; j++) {
			int u;
			read(u);
			u--, u = (u + R) % n;
			vec_v.push_back(g1.bcc[u]);
		}
		for (int j = 0; j < E; j++) {
			int u, v;
			read(u), read(v);
			u--, u = (u + R) % n;
			v--, v = (v + R) % n;
			vec_e.push_back(make_pair(g1.bcc[u], g1.bcc[v]));
			vec_v.push_back(g1.bcc[u]), vec_v.push_back(g1.bcc[v]);
		}

		sort(vec_v.begin(), vec_v.end(), cmp);

		stk[top = 0] = g1.t;
		for (int j = 0; j < vec_v.size(); j++) {
			int p = lca(vec_v[j], stk[top]);
			while (top && id[stk[top - 1]] >= id[p]) {
				vec_e.push_back(make_pair(stk[top - 1], stk[top]));
				top--;
			}
			if (p != stk[top]) {
				vec_e.push_back(make_pair(p, stk[top]));
				stk[top] = p;
			}
			if (stk[top] != vec_v[j]) stk[++top] = vec_v[j];
		}

		while (top) {
			vec_e.push_back(make_pair(stk[top - 1], stk[top]));
			top--;
		}

		vec_v.clear();
		for (int j = 0; j < vec_e.size(); j++) {
			vec_v.push_back(vec_e[j].first);
			vec_v.push_back(vec_e[j].second);
		}

		sort(vec_v.begin(), vec_v.end());
		int s = unique(vec_v.begin(), vec_v.end()) - vec_v.begin();
		g2.init(s);

		for (int j = 0; j < vec_e.size(); j++) {
			if (vec_e[j].first == g1.t) continue;
			if (vec_e[j].second == g1.t) continue;
			int u = lower_bound(vec_v.begin(), vec_v.begin() + s, vec_e[j].first) - vec_v.begin();
			int v = lower_bound(vec_v.begin(), vec_v.begin() + s, vec_e[j].second) - vec_v.begin();
			g2.addedge(u, v), g2.addedge(v, u);
		}

		g2.get_bcc();
		bool flag = true;
		for (int j = 1; j < vec.size(); j++) {
			int u = lower_bound(vec_v.begin(), vec_v.begin() + s, vec[j]) - vec_v.begin();
			int v = lower_bound(vec_v.begin(), vec_v.begin() + s, vec[0]) - vec_v.begin();
			if (g2.bcc[u] != g2.bcc[v]) flag = false;
		}
		if (flag) puts("YES"), R = (R + i) % n;
		else puts("NO");
	}
	return 0;
}
//
//


#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 300005, M = 300005, LOGN = 21;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}

template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x +'0');
	else write(x / 10), putchar(x % 10 + '0');
}

struct edge {
	int to, nxt;
} ;
struct graph {
	int V, head[N], cnt;
	edge g[M << 1];
	void init (int v) {
		V = v;
		for (int i = 0; i < v; i++) head[i] = -1;
		cnt = 0;
	}

	void addedge (int u, int v) {
		edge e = {v, head[u]};
		g[head[u] = cnt++] = e;
	}

	int low[N], dfn[N], bcc[N], tot, t;
	stack<int> stk;

	void dfs (int u, int fa) {
		low[u] = dfn[u] = ++tot;
		stk.push(u);
		for (int i = head[u]; ~i; i = g[i].nxt) {
			int v = g[i].to;
			if (i != fa) {
				if (!dfn[v]) dfs(v, i ^ 1), low[u] = min(low[u], low[v]);
				else low[u] = min(low[u], dfn[v]);
			}
		}

		if (low[u] == dfn[u]) {
			for (; ;) {
				int x = stk.top();
				bcc[x] = t, stk.pop();
				if (x == u) break;
			}
			t++;
		}
	}
	void get_bcc () {
		tot = t = 0;
		for (int i = 0; i < V; i++) low[i] = dfn[i] = 0;
		for (int i = 0; i < V; i++) {
			if (!dfn[i]) dfs(i, -1);
		}
	}
} g1, tree, g2;

int dep[N], euler[N << 1][LOGN], id[N], Log2[N << 1], cnt = 0;
void dfs (int u, int fa) {
	euler[id[u] = ++cnt][0] = u;
	for (int i = tree.head[u]; ~i; i = tree.g[i].nxt) {
		int v = tree.g[i].to;
		if (v != fa) {
			dep[v] = dep[u] + 1;
			dfs(v, u);
			euler[++cnt][0] = u;
		}
	}
}

void rmq_init () {
	for (int i = 1; i <= cnt; i++) {
		for (int j = 1; (1 << j) <= i; j++) {
			if (dep[euler[i][j - 1]] < dep[euler[i - (1 << (j - 1))][j - 1]]) euler[i][j] = euler[i][j - 1];
			else euler[i][j] = euler[i - (1 << (j - 1))][j - 1];
		}
	}
	Log2[1] = 0;
	for (int i = 2; i <= cnt; i++) Log2[i] = Log2[i >> 1] + 1;
}

int lca (int u, int v) {
	int l = id[u], r = id[v];
	if (l > r) swap(l, r);
	int label = Log2[r - l + 1];
	if (dep[euler[r][label]] < dep[euler[l + (1 << label) - 1][label]]) return euler[r][label];
	return euler[l + (1 << label) - 1][label];
}

int n, m, q, stk[N], R = 0, top = 0;
vector<int> vec, vec_v;
vector<pair<int, int> > vec_e;

bool cmp (int x, int y) {
	return id[x] < id[y];
}
int main () {
	read(n), read(m), read(q);
	g1.init(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		read(u), read(v);
		u--, v--;
		g1.addedge(u, v), g1.addedge(v, u);
	}

	g1.get_bcc();
	tree.init(g1.t + 1);
	for (int i = 0; i < n; i++) {
		for (int j = g1.head[i]; ~j; j = g1.g[j].nxt) {
			int u = i, v = g1.g[j].to;
			if (g1.bcc[u] != g1.bcc[v]) tree.addedge(g1.bcc[u], g1.bcc[v]);
		}
	}

	for (int i = 0; i < g1.t; i++) dep[i] = 0;
	euler[id[g1.t] = ++cnt][0] = g1.t;
	for (int i = 0; i < g1.t; i++) {
		if (!dep[i]) {
			tree.addedge(g1.t, i), tree.addedge(i, g1.t);
			dep[i] = 1, dfs(i, g1.t);
			euler[++cnt][0] = g1.t;
		}
	}
	rmq_init();

	for (int i = 1; i <= q; i++) {
		vec.clear(), vec_v.clear(), vec_e.clear();
		int V, E;
		read(V), read(E);
		for (int j = 0; j < V; j++) {
			int u;
			read(u);
			u--, u = (u + R) % n;
			vec_v.push_back(g1.bcc[u]), vec.push_back(g1.bcc[u]);
		}
		for (int j = 0; j < E; j++) {
			int u, v;
			read(u), read(v);
			u--, u = (u + R) % n;
			v--, v = (v + R) % n;
			vec_e.push_back(make_pair(g1.bcc[u], g1.bcc[v]));
			vec_v.push_back(g1.bcc[u]), vec_v.push_back(g1.bcc[v]);
		}

		sort(vec_v.begin(), vec_v.end(), cmp);
		stk[top = 0] = g1.t;
		for (int j = 1; j < vec_v.size(); j++) {
			int p = lca(vec_v[j], stk[top]);
			while (top && id[stk[top - 1]] >= id[p]) {
				vec_e.push_back(make_pair(stk[top - 1], stk[top]));
				top--;
			}
			if (p != stk[top]) {
				vec_e.push_back(make_pair(p, stk[top]));
				stk[top] = p;
			}
			if (stk[top] != vec_v[j]) stk[++top] = vec_v[j];
		}

		while (top) {
			vec_e.push_back(make_pair(stk[top - 1], stk[top]));
			top--;
		}

		vec_v.clear();
		for (int j = 0; j < vec_e.size(); j++) {
			vec_v.push_back(vec_e[j].first);
			vec_v.push_back(vec_e[j].second);
		}
		sort(vec_v.begin(), vec_v.end());
		int s = unique(vec_v.begin(), vec_v.end()) - vec_v.begin();
		g2.init(s);
		for (int j = 0; j < vec_e.size(); j++) {
			if (vec_e[j].first == g1.t) continue;
			if (vec_e[j].second == g1.t) continue;
			int u = lower_bound(vec_v.begin(), vec_v.begin() + s, vec_e[j].first) - vec_v.begin();
			int v = lower_bound(vec_v.begin(), vec_v.begin() + s, vec_e[j].second) - vec_v.begin();
			g2.addedge(u, v), g2.addedge(v, u);
		}

		g2.get_bcc();
		bool flag = true;
		for (int j = 1; j < vec.size(); j++) {
			int u = lower_bound(vec_v.begin(), vec_v.begin() + s, vec[j]) - vec_v.begin();
			int v = lower_bound(vec_v.begin(), vec_v.begin() + s, vec[0]) - vec_v.begin();
			if (g2.bcc[u] != g2.bcc[v]) flag = false;
		}
		if (flag) puts("YES"), R = (R + i) % n;
		else puts("NO");
	}
	return 0;
}


#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 300005, M = 300005, LOGN = 21;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}

template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x +'0');
	else write(x / 10), putchar(x % 10 + '0');
}

struct edge {
	int to, nxt;
} ;
struct graph {
	int V, head[N], cnt;
	edge g[M << 1];
	void init (int v) {
		V = v;
		for (int i = 0; i < v; i++) head[i] = -1;
		cnt = 0;
	}

	void addedge (int u, int v) {
		edge e = {v, head[u]};
		g[head[u] = cnt++] = e;
	}

	int low[N], dfn[N], bcc[N], tot, t;
	stack<int> stk;

	void dfs (int u, int fa) {
		low[u] = dfn[u] = ++tot;
		stk.push(u);
		for (int i = head[u]; ~i; i = g[i].nxt) {
			int v = g[i].to;
			if (i != fa) {
				if (!dfn[v]) dfs(v, i ^ 1), low[u] = min(low[u], low[v]);
				else low[u] = min(low[u], dfn[v]);
			}
		}

		if (low[u] == dfn[u]) {
			for (; ;) {
				int x = stk.top();
				bcc[x] = t, stk.pop();
				if (x == u) break;
			}
			t++;
		}
	}
	void get_bcc () {
		tot = t = 0;
		for (int i = 0; i < V; i++) low[i] = dfn[i] = 0;
		for (int i = 0; i < V; i++) {
			if (!dfn[i]) dfs(i, -1);
		}
	}
} g1, tree, g2;

int dep[N], euler[N << 1][LOGN], id[N], Log2[N << 1], cnt = 0;
void dfs (int u, int fa) {
	euler[id[u] = ++cnt][0] = u;
	for (int i = tree.head[u]; ~i; i = tree.g[i].nxt) {
		int v = tree.g[i].to;
		if (v != fa) {
			dep[v] = dep[u] + 1;
			dfs(v, u);
			euler[++cnt][0] = u;
		}
	}
}

void rmq_init () {
	for (int i = 1; i <= cnt; i++) {
		for (int j = 1; (1 << j) <= i; j++) {
			if (dep[euler[i][j - 1]] < dep[euler[i - (1 << (j - 1))][j - 1]]) euler[i][j] = euler[i][j - 1];
			else euler[i][j] = euler[i - (1 << (j - 1))][j - 1];
		}
	}
	Log2[1] = 0;
	for (int i = 2; i <= cnt; i++) Log2[i] = Log2[i >> 1] + 1;
}

int lca (int u, int v) {
	int l = id[u], r = id[v];
	if (l > r) swap(l, r);
	int label = Log2[r - l + 1];
	if (dep[euler[r][label]] < dep[euler[l + (1 << label) - 1][label]]) return euler[r][label];
	return euler[l + (1 << label) - 1][label];
}

int n, m, q, stk[N], R = 0, top = 0;
vector<int> vec, vec_v;
vector<pair<int, int> > vec_e;

bool cmp (int x, int y) {
	return id[x] < id[y];
}
int main () {
	read(n), read(m), read(q);
	g1.init(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		read(u), read(v);
		u--, v--;
		g1.addedge(u, v), g1.addedge(v, u);
	}

	g1.get_bcc();
	tree.init(g1.t + 1);
	for (int i = 0; i < n; i++) {
		for (int j = g1.head[i]; ~j; j = g1.g[j].nxt) {
			int u = i, v = g1.g[j].to;
			if (g1.bcc[u] != g1.bcc[v]) tree.addedge(g1.bcc[u], g1.bcc[v]);
		}
	}

	for (int i = 0; i <= g1.t; i++) dep[i] = 0;
	euler[id[g1.t] = ++cnt][0] = g1.t;
	for (int i = 0; i < g1.t; i++) {
		if (!dep[i]) {
			tree.addedge(g1.t, i), tree.addedge(i, g1.t);
			dep[i] = 1, dfs(i, g1.t);
			euler[++cnt][0] = g1.t;
		}
	}
	rmq_init();

	for (int i = 1; i <= q; i++) {
		vec.clear(), vec_v.clear(), vec_e.clear();
		int V, E;
		read(V), read(E);
		for (int j = 0; j < V; j++) {
			int u;
			read(u);
			u--, u = (u + R) % n;
			vec_v.push_back(g1.bcc[u]);
		}
		for (int j = 0; j < E; j++) {
			int u, v;
			read(u), read(v);
			u--, u = (u + R) % n;
			v--, v = (v + R) % n;
			vec_e.push_back(make_pair(g1.bcc[u], g1.bcc[v]));
			vec_v.push_back(g1.bcc[u]), vec_v.push_back(g1.bcc[v]);
		}

		sort(vec_v.begin(), vec_v.end(), cmp);

		stk[top = 0] = g1.t;
		for (int j = 0; j < vec_v.size(); j++) {
			int p = lca(vec_v[j], stk[top]);
			while (top && id[stk[top - 1]] >= id[p]) {
				vec_e.push_back(make_pair(stk[top - 1], stk[top]));
				top--;
			}
			if (p != stk[top]) {
				vec_e.push_back(make_pair(p, stk[top]));
				stk[top] = p;
			}
			if (stk[top] != vec_v[j]) stk[++top] = vec_v[j];
		}

		while (top) {
			vec_e.push_back(make_pair(stk[top - 1], stk[top]));
			top--;
		}

		vec_v.clear();
		for (int j = 0; j < vec_e.size(); j++) {
			vec_v.push_back(vec_e[j].first);
			vec_v.push_back(vec_e[j].second);
		}

		sort(vec_v.begin(), vec_v.end());
		int s = unique(vec_v.begin(), vec_v.end()) - vec_v.begin();
		g2.init(s);

		for (int j = 0; j < vec_e.size(); j++) {
			if (vec_e[j].first == g1.t) continue;
			if (vec_e[j].second == g1.t) continue;
			int u = lower_bound(vec_v.begin(), vec_v.begin() + s, vec_e[j].first) - vec_v.begin();
			int v = lower_bound(vec_v.begin(), vec_v.begin() + s, vec_e[j].second) - vec_v.begin();
			g2.addedge(u, v), g2.addedge(v, u);
		}

		g2.get_bcc();
		bool flag = true;
		for (int j = 1; j < vec.size(); j++) {
			int u = lower_bound(vec_v.begin(), vec_v.begin() + s, vec[j]) - vec_v.begin();
			int v = lower_bound(vec_v.begin(), vec_v.begin() + s, vec[0]) - vec_v.begin();
			if (g2.bcc[u] != g2.bcc[v]) flag = false;
		}
		if (flag) puts("YES"), R = (R + i) % n;
		else puts("NO");
	}
	return 0;
}


#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 300005, M = 300005, LOGN = 21;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}

template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x +'0');
	else write(x / 10), putchar(x % 10 + '0');
}

struct edge {
	int to, nxt;
} ;
struct graph {
	int V, head[N], cnt;
	edge g[M << 1];
	void init (int v) {
		V = v;
		for (int i = 0; i < v; i++) head[i] = -1;
		cnt = 0;
	}

	void addedge (int u, int v) {
		edge e = {v, head[u]};
		g[head[u] = cnt++] = e;
	}

	int low[N], dfn[N], bcc[N], tot, t;
	stack<int> stk;

	void dfs (int u, int fa) {
		low[u] = dfn[u] = ++tot;
		stk.push(u);
		for (int i = head[u]; ~i; i = g[i].nxt) {
			int v = g[i].to;
			if (i != fa) {
				if (!dfn[v]) dfs(v, i ^ 1), low[u] = min(low[u], low[v]);
				else low[u] = min(low[u], dfn[v]);
			}
		}

		if (low[u] == dfn[u]) {
			for (; ;) {
				int x = stk.top();
				bcc[x] = t, stk.pop();
				if (x == u) break;
			}
			t++;
		}
	}
	void get_bcc () {
		tot = t = 0;
		for (int i = 0; i < V; i++) low[i] = dfn[i] = 0;
		for (int i = 0; i < V; i++) {
			if (!dfn[i]) dfs(i, -1);
		}
	}
} g1, tree, g2;

int dep[N], euler[N << 1][LOGN], id[N], Log2[N << 1], cnt = 0;
void dfs (int u, int fa) {
	euler[id[u] = ++cnt][0] = u;
	for (int i = tree.head[u]; ~i; i = tree.g[i].nxt) {
		int v = tree.g[i].to;
		if (v != fa) {
			dep[v] = dep[u] + 1;
			dfs(v, u);
			euler[++cnt][0] = u;
		}
	}
}

void rmq_init () {
	for (int i = 1; i <= cnt; i++) {
		for (int j = 1; (1 << j) <= i; j++) {
			if (dep[euler[i][j - 1]] < dep[euler[i - (1 << (j - 1))][j - 1]]) euler[i][j] = euler[i][j - 1];
			else euler[i][j] = euler[i - (1 << (j - 1))][j - 1];
		}
	}
	Log2[1] = 0;
	for (int i = 2; i <= cnt; i++) Log2[i] = Log2[i >> 1] + 1;
}

int lca (int u, int v) {
	int l = id[u], r = id[v];
	if (l > r) swap(l, r);
	int label = Log2[r - l + 1];
	if (dep[euler[r][label]] < dep[euler[l + (1 << label) - 1][label]]) return euler[r][label];
	return euler[l + (1 << label) - 1][label];
}

int n, m, q, stk[N], R = 0, top = 0;
vector<int> vec, vec_v;
vector<pair<int, int> > vec_e;

bool cmp (int x, int y) {
	return id[x] < id[y];
}
int main () {
	read(n), read(m), read(q);
	g1.init(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		read(u), read(v);
		u--, v--;
		g1.addedge(u, v), g1.addedge(v, u);
	}

	g1.get_bcc();
	tree.init(g1.t + 1);
	for (int i = 0; i < n; i++) {
		for (int j = g1.head[i]; ~j; j = g1.g[j].nxt) {
			int u = i, v = g1.g[j].to;
			if (g1.bcc[u] != g1.bcc[v]) tree.addedge(g1.bcc[u], g1.bcc[v]);
		}
	}

	for (int i = 0; i <= g1.t; i++) dep[i] = 0;
	euler[id[g1.t] = ++cnt][0] = g1.t;
	for (int i = 0; i < g1.t; i++) {
		if (!dep[i]) {
			tree.addedge(g1.t, i), tree.addedge(i, g1.t);
			dep[i] = 1, dfs(i, g1.t);
			euler[++cnt][0] = g1.t;
		}
	}
	rmq_init();

	for (int i = 1; i <= q; i++) {
		vec.clear(), vec_v.clear(), vec_e.clear();
		int V, E;
		read(V), read(E);
		for (int j = 0; j < V; j++) {
			int u;
			read(u);
			u--, u = (u + R) % n;
			vec_v.push_back(g1.bcc[u]);
		}
		for (int j = 0; j < E; j++) {
			int u, v;
			read(u), read(v);
			u--, u = (u + R) % n;
			v--, v = (v + R) % n;
			vec_e.push_back(make_pair(g1.bcc[u], g1.bcc[v]));
			vec_v.push_back(g1.bcc[u]), vec_v.push_back(g1.bcc[v]);
		}

		sort(vec_v.begin(), vec_v.end(), cmp);

		stk[top = 0] = g1.t;
		for (int j = 0; j < vec_v.size(); j++) {
			int p = lca(vec_v[j], stk[top]);
			while (top && id[stk[top - 1]] >= id[p]) {
				vec_e.push_back(make_pair(stk[top - 1], stk[top]));
				top--;
			}
			if (p != stk[top]) {
				vec_e.push_back(make_pair(p, stk[top]));
				stk[top] = p;
			}
			if (stk[top] != vec_v[j]) stk[++top] = vec_v[j];
		}

		while (top) {
			vec_e.push_back(make_pair(stk[top - 1], stk[top]));
			top--;
		}

		vec_v.clear();
		for (int j = 0; j < vec_e.size(); j++) {
			vec_v.push_back(vec_e[j].first);
			vec_v.push_back(vec_e[j].second);
		}

		sort(vec_v.begin(), vec_v.end());
		int s = unique(vec_v.begin(), vec_v.end()) - vec_v.begin();
		g2.init(s);

		for (int j = 0; j < vec_e.size(); j++) {
			if (vec_e[j].first == g1.t) continue;
			if (vec_e[j].second == g1.t) continue;
			int u = lower_bound(vec_v.begin(), vec_v.begin() + s, vec_e[j].first) - vec_v.begin();
			int v = lower_bound(vec_v.begin(), vec_v.begin() + s, vec_e[j].second) - vec_v.begin();
			g2.addedge(u, v), g2.addedge(v, u);
		}

		g2.get_bcc();
		bool flag = true;
		for (int j = 1; j < vec.size(); j++) {
			int u = lower_bound(vec_v.begin(), vec_v.begin() + s, vec[j]) - vec_v.begin();
			int v = lower_bound(vec_v.begin(), vec_v.begin() + s, vec[0]) - vec_v.begin();
			if (g2.bcc[u] != g2.bcc[v]) flag = false;
		}
		if (flag) puts("YES"), R = (R + i) % n;
		else puts("NO");
		R = 0;
		debug(i);
	}
	return 0;
}


#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 300005, M = 300005, LOGN = 21;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}

template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x +'0');
	else write(x / 10), putchar(x % 10 + '0');
}

struct edge {
	int to, nxt;
} ;
struct graph {
	int V, head[N], cnt;
	edge g[M << 1];
	void init (int v) {
		V = v;
		for (int i = 0; i < v; i++) head[i] = -1;
		cnt = 0;
	}

	void addedge (int u, int v) {
		edge e = {v, head[u]};
		g[head[u] = cnt++] = e;
	}

	int low[N], dfn[N], bcc[N], tot, t;
	stack<int> stk;

	void dfs (int u, int fa) {
		low[u] = dfn[u] = ++tot;
		stk.push(u);
		for (int i = head[u]; ~i; i = g[i].nxt) {
			int v = g[i].to;
			if (i != fa) {
				if (!dfn[v]) dfs(v, i ^ 1), low[u] = min(low[u], low[v]);
				else low[u] = min(low[u], dfn[v]);
			}
		}

		if (low[u] == dfn[u]) {
			for (; ;) {
				int x = stk.top();
				bcc[x] = t, stk.pop();
				if (x == u) break;
			}
			t++;
		}
	}
	void get_bcc () {
		tot = t = 0;
		for (int i = 0; i < V; i++) low[i] = dfn[i] = 0;
		for (int i = 0; i < V; i++) {
			if (!dfn[i]) dfs(i, -1);
		}
	}
} g1, tree, g2;

int dep[N], euler[N << 1][LOGN], id[N], Log2[N << 1], cnt = 0;
void dfs (int u, int fa) {
	euler[id[u] = ++cnt][0] = u;
	for (int i = tree.head[u]; ~i; i = tree.g[i].nxt) {
		int v = tree.g[i].to;
		if (v != fa) {
			dep[v] = dep[u] + 1;
			dfs(v, u);
			euler[++cnt][0] = u;
		}
	}
}

void rmq_init () {
	for (int i = 1; i <= cnt; i++) {
		for (int j = 1; (1 << j) <= i; j++) {
			if (dep[euler[i][j - 1]] < dep[euler[i - (1 << (j - 1))][j - 1]]) euler[i][j] = euler[i][j - 1];
			else euler[i][j] = euler[i - (1 << (j - 1))][j - 1];
		}
	}
	Log2[1] = 0;
	for (int i = 2; i <= cnt; i++) Log2[i] = Log2[i >> 1] + 1;
}

int lca (int u, int v) {
	int l = id[u], r = id[v];
	if (l > r) swap(l, r);
	int label = Log2[r - l + 1];
	if (dep[euler[r][label]] < dep[euler[l + (1 << label) - 1][label]]) return euler[r][label];
	return euler[l + (1 << label) - 1][label];
}

int n, m, q, stk[N], R = 0, top = 0;
vector<int> vec, vec_v;
vector<pair<int, int> > vec_e;

bool cmp (int x, int y) {
	return id[x] < id[y];
}
int main () {
	read(n), read(m), read(q);
	g1.init(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		read(u), read(v);
		u--, v--;
		g1.addedge(u, v), g1.addedge(v, u);
	}

	g1.get_bcc();
	tree.init(g1.t);
	for (int i = 0; i < n; i++) {
		for (int j = g1.head[i]; ~j; j = g1.g[j].nxt) {
			int u = i, v = g1.g[j].to;
			if (g1.bcc[u] != g1.bcc[v]) tree.addedge(g1.bcc[u], g1.bcc[v]);
		}
	}
	dep[0] = 0, dfs(0, -1);
	rmq_init();

	for (int i = 1; i <= q; i++) {
		vec.clear(), vec_v.clear(), vec_e.clear();
		int V, E;
		read(V), read(E);
		for (int j = 0; j < V; j++) {
			int u;
			read(u);
			u--, u = (u + R) % n;
			vec_v.push_back(g1.bcc[u]), vec.push_back(g1.bcc[u]);
		}
		for (int j = 0; j < E; j++) {
			int u, v;
			read(u), read(v);
			u--, u = (u + R) % n;
			v--, v = (v + R) % n;
			vec_e.push_back(make_pair(g1.bcc[u], g1.bcc[v]));
			vec_v.push_back(g1.bcc[u]), vec_v.push_back(g1.bcc[v]);
		}

		sort(vec_v.begin(), vec_v.end(), cmp);
		stk[top = 0] = 0;
		for (int j = 1; j < vec_v.size(); j++) {
			int p = lca(vec_v[j], stk[top]);
			while (top && id[stk[top - 1]] >= id[p]) {
				vec_e.push_back(make_pair(stk[top - 1], stk[top]));
				top--;
			}
			if (p != stk[top]) {
				vec_e.push_back(make_pair(p, stk[top]));
				stk[top] = p;
			}
			if (stk[top] != vec_v[j]) stk[++top] = vec_v[j];
		}

		while (top) {
			vec_e.push_back(make_pair(stk[top - 1], stk[top]));
			top--;
		}

		vec_v.clear();
		for (int j = 0; j < vec_e.size(); j++) {
			vec_v.push_back(vec_e[j].first);
			vec_v.push_back(vec_e[j].second);
		}
		sort(vec_v.begin(), vec_v.end());
		int s = unique(vec_v.begin(), vec_v.end()) - vec_v.begin();
		g2.init(s);
		for (int j = 0; j < vec_e.size(); j++) {
			int u = lower_bound(vec_v.begin(), vec_v.begin() + s, vec_e[j].first) - vec_v.begin();
			int v = lower_bound(vec_v.begin(), vec_v.begin() + s, vec_e[j].second) - vec_v.begin();
			g2.addedge(u, v), g2.addedge(v, u);
		}

		g2.get_bcc();
		bool flag = true;
		for (int j = 1; j < vec.size(); j++) {
			int u = lower_bound(vec_v.begin(), vec_v.begin() + s, vec[j]) - vec_v.begin();
			int v = lower_bound(vec_v.begin(), vec_v.begin() + s, vec[0]) - vec_v.begin();
			if (g2.bcc[u] != g2.bcc[v]) flag = false;
		}
		if (flag) puts("YES"), R = (R + i) % n;
		else puts("NO");
	}
	return 0;
}


#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 300005, M = 300005, LOGN = 21;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}

template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x +'0');
	else write(x / 10), putchar(x % 10 + '0');
}

struct edge {
	int to, nxt;
} ;
struct graph {
	int V, head[N], cnt;
	edge g[M << 1];
	void init (int v) {
		V = v;
		for (int i = 0; i < v; i++) head[i] = -1;
		cnt = 0;
	}

	void addedge (int u, int v) {
		edge e = {v, head[u]};
		g[head[u] = cnt++] = e;
	}

	int low[N], dfn[N], bcc[N], tot, t;
	stack<int> stk;

	void dfs (int u, int fa) {
		low[u] = dfn[u] = ++tot;
		stk.push(u);
		for (int i = head[u]; ~i; i = g[i].nxt) {
			int v = g[i].to;
			if (i != fa) {
				if (!dfn[v]) dfs(v, i ^ 1), low[u] = min(low[u], low[v]);
				else low[u] = min(low[u], dfn[v]);
			}
		}

		if (low[u] == dfn[u]) {
			for (; ;) {
				int x = stk.top();
				bcc[x] = t, stk.pop();
				if (x == u) break;
			}
			t++;
		}
	}
	void get_bcc () {
		tot = t = 0;
		for (int i = 0; i < V; i++) low[i] = dfn[i] = 0;
		for (int i = 0; i < V; i++) {
			if (!dfn[i]) dfs(i, -1);
		}
	}
} g1, tree, g2;

int dep[N], euler[N << 1][LOGN], id[N], Log2[N << 1], cnt = 0;
void dfs (int u, int fa) {
	euler[id[u] = ++cnt][0] = u;
	for (int i = tree.head[u]; ~i; i = tree.g[i].nxt) {
		int v = tree.g[i].to;
		if (v != fa) {
			dep[v] = dep[u] + 1;
			dfs(v, u);
			euler[++cnt][0] = u;
		}
	}
}

void rmq_init () {
	for (int i = 1; i <= cnt; i++) {
		for (int j = 1; (1 << j) <= i; j++) {
			if (dep[euler[i][j - 1]] < dep[euler[i - (1 << (j - 1))][j - 1]]) euler[i][j] = euler[i][j - 1];
			else euler[i][j] = euler[i - (1 << (j - 1))][j - 1];
		}
	}
	Log2[1] = 0;
	for (int i = 2; i <= cnt; i++) Log2[i] = Log2[i >> 1] + 1;
}

int lca (int u, int v) {
	int l = id[u], r = id[v];
	if (l > r) swap(l, r);
	int label = Log2[r - l + 1];
	if (dep[euler[r][label]] < dep[euler[l + (1 << label) - 1][label]]) return euler[r][label];
	return euler[l + (1 << label) - 1][label];
}

int n, m, q, stk[N], R = 0, top = 0;
vector<int> vec, vec_v;
vector<pair<int, int> > vec_e;

bool cmp (int x, int y) {
	return id[x] < id[y];
}
int main () {
	read(n), read(m), read(q);
	g1.init(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		read(u), read(v);
		u--, v--;
		g1.addedge(u, v), g1.addedge(v, u);
	}

	g1.get_bcc();
	tree.init(g1.t + 1);
	for (int i = 0; i < n; i++) {
		for (int j = g1.head[i]; ~j; j = g1.g[j].nxt) {
			int u = i, v = g1.g[j].to;
			if (g1.bcc[u] != g1.bcc[v]) tree.addedge(g1.bcc[u], g1.bcc[v]);
		}
	}

	for (int i = 0; i <= g1.t; i++) dep[i] = 0;
	euler[id[g1.t] = ++cnt][0] = g1.t;
	for (int i = 0; i < g1.t; i++) {
		if (!dep[i]) {
			tree.addedge(g1.t, i), tree.addedge(i, g1.t);
			dep[i] = 1, dfs(i, g1.t);
			euler[++cnt][0] = g1.t;
		}
	}
	rmq_init();

	for (int i = 1; i <= q; i++) {
		vec.clear(), vec_v.clear(), vec_e.clear();
		int V, E;
		read(V), read(E);
		for (int j = 0; j < V; j++) {
			int u;
			read(u);
			u--, u = (u + R) % n;
			vec_v.push_back(g1.bcc[u]), vec.push_back(g1.bcc[u]);
		}
		for (int j = 0; j < E; j++) {
			int u, v;
			read(u), read(v);
			u--, u = (u + R) % n;
			v--, v = (v + R) % n;
			vec_e.push_back(make_pair(g1.bcc[u], g1.bcc[v]));
			vec_v.push_back(g1.bcc[u]), vec_v.push_back(g1.bcc[v]);
		}

		sort(vec_v.begin(), vec_v.end(), cmp);

		stk[top = 0] = g1.t;
		for (int j = 0; j < vec_v.size(); j++) {
			int p = lca(vec_v[j], stk[top]);
			while (top && id[stk[top - 1]] >= id[p]) {
				vec_e.push_back(make_pair(stk[top - 1], stk[top]));
				top--;
			}
			if (p != stk[top]) {
				vec_e.push_back(make_pair(p, stk[top]));
				stk[top] = p;
			}
			if (stk[top] != vec_v[j]) stk[++top] = vec_v[j];
		}

		while (top) {
			vec_e.push_back(make_pair(stk[top - 1], stk[top]));
			top--;
		}

		vec_v.clear();
		for (int j = 0; j < vec_e.size(); j++) {
			vec_v.push_back(vec_e[j].first);
			vec_v.push_back(vec_e[j].second);
		}

		sort(vec_v.begin(), vec_v.end());
		int s = unique(vec_v.begin(), vec_v.end()) - vec_v.begin();
		g2.init(s);

		for (int j = 0; j < vec_e.size(); j++) {
			if (vec_e[j].first == g1.t) continue;
			if (vec_e[j].second == g1.t) continue;
			int u = lower_bound(vec_v.begin(), vec_v.begin() + s, vec_e[j].first) - vec_v.begin();
			int v = lower_bound(vec_v.begin(), vec_v.begin() + s, vec_e[j].second) - vec_v.begin();
			g2.addedge(u, v), g2.addedge(v, u);
		}

		g2.get_bcc();
		bool flag = true;
		for (int j = 1; j < vec.size(); j++) {
			int u = lower_bound(vec_v.begin(), vec_v.begin() + s, vec[j]) - vec_v.begin();
			int v = lower_bound(vec_v.begin(), vec_v.begin() + s, vec[0]) - vec_v.begin();
			if (g2.bcc[u] != g2.bcc[v]) flag = false;
		}
		if (flag) puts("YES"), R = (R + i) % n;
		else puts("NO");
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define cri const register int
#define re register
using namespace std;
int dfn[300010],low[300010],bl[300010],obl[300010],in[300010];
int fa[300010],to[600010],la[600010],cnt=1,dcc;
int t[1000010],sta[300010],top,tmp[300010],num,cut[600010];
inline void add(cri x,cri y){
	to[++cnt]=y,la[cnt]=fa[x],fa[x]=cnt;cut[cnt]=0;
	to[++cnt]=x,la[cnt]=fa[y],fa[y]=cnt;cut[cnt]=0;
	//cout<<x<<" link "<<y<<endl;
}
void tj(cri x,cri in){
	dfn[x]=low[x]=++num;//cout<<x<<" "<<dfn[x]<<" "<<fa[x]<<" "<<to[fa[x]]<<endl;
	for(int i=fa[x];i;i=la[i])if(to[i]){
		if(!dfn[to[i]]){
			tj(to[i],i);
			low[x]=min(low[x],low[to[i]]);
			if(low[to[i]]>dfn[x]) cut[i]=cut[i^1]=1;//,cout<<low[to[i]]<<" "<<dfn[x]<<" "<<x<<" cut "<<to[i]<<endl;
		}
		else if(i!=(in^1)) low[x]=min(low[x],dfn[to[i]]);
	}
}
void dfs(cri x,cri ff){
	bl[x]=dcc;
	for(int i=fa[x];i;i=la[i]) if(!bl[to[i]]&&!cut[i]&&to[i]) dfs(to[i],x);
}
int ST[20][600010],bin[600010],dep[300010];
void dfss(cri x,cri ff){
	in[x]=++num;
	//cout<<x<<" "<<in[x]<<endl;
	ST[0][num]=x;dep[x]=dep[ff]+1;
	for(int i=fa[x];i;i=la[i]) if(to[i]!=ff) dfss(to[i],x),ST[0][++num]=x;
}
inline int Min(cri x,cri y){
	return dep[x]<dep[y]?x:y;
}
inline int as(cri x,cri y){
	return in[x]<in[y];
}
inline int lca(int x,int y){
	x=in[x];y=in[y];
	if(x>y) swap(x,y);
	cri b=bin[y-x+1];
	return Min(ST[b][y],ST[b][x+(1<<b)-1]);
}
inline void build(){
	for(int i=2;i<=num;i++) bin[i]=bin[i>>1]+1;
	for(int i=1;i<=num;i++)
		for(int j=1;(1<<j)<=i;j++) ST[j][i]=Min(ST[j-1][i],ST[j-1][i-(1<<j-1)]);
}
inline void insert(cri x){
	if(top==1) return ;
	cri L=lca(x,sta[top]);
	if(L==sta[top]) return ;
	while(top>1&&in[sta[top-1]]>=in[L]) add(sta[top-1],sta[top]),top--;
	if(L!=sta[top]) add(L,sta[top]),sta[top]=L,tmp[++tmp[0]]=L;
}
inline int read(re int a=0,re char ch=getchar()){
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') a=(a<<3)+(a<<1)+(ch^48),ch=getchar();
	return a;
}
int G[300010];
int main(){
	cri n=read(),m=read(),q=read();
	for(int i=1;i<=m;i++) add(read(),read());
	for(int i=1;i<=n;i++) if(!dfn[i]) tj(i,0);
	for(int i=1;i<=n;i++) if(!bl[i]) dcc++,dfs(i,0);
	memset(fa,0,sizeof fa);
	memset(dfn,0,sizeof dfn);
	cnt=num=0;
	for(int i=2;i<=m*2;i+=2) if(bl[to[i]]!=bl[to[i^1]]) add(bl[to[i]],bl[to[i^1]]);
	for(int i=1;i<=dcc;i++) if(!in[i]) add(0,i),dfss(i,0);
	num=0;
	dfss(0,0);
	memset(fa,0,sizeof fa);cnt=1;
	memset(cut,0,sizeof cut);
	build();
	for(int i=1;i<=n;i++) obl[i]=bl[i],bl[i]=0;//puts("");
	for(int T=1;T<=q;T++){
		int ni=read(),mi=read();tmp[0]=G[0]=num=dcc=0;cnt=1;
		for(int i=1;i<=ni;i++) G[++G[0]]=t[i]=obl[read()];//cout<<t[i]<<" ";puts("");
		for(int i=1;i<=mi;i++){
			cri x=obl[read()],y=obl[read()];
			if(x!=y) add(x,y),t[++ni]=x,t[++ni]=y;
		}
		sort(t+1,t+ni+1,as);
		ni=unique(t+1,t+ni+1)-t-1;
		for(int i=1;i<=ni;i++) tmp[++tmp[0]]=t[i];//,cout<<t[i]<<" ";puts("");
		sta[top=1]=t[1];
		for(int i=2;i<=ni;i++) insert(t[i]),sta[++top]=t[i];
		while(top>1) add(sta[top-1],sta[top]),top--;
		for(int i=1;i<=tmp[0];i++) if(!dfn[tmp[i]]) tj(tmp[i],0);//cout<<1<<endl;
		for(int i=1;i<=tmp[0];i++) if(!bl[tmp[i]]&&tmp[i]) dcc++,dfs(tmp[i],0);
		int is=bl[G[1]];
		for(int i=2;i<=G[0];i++) if(bl[G[i]]!=is){
			puts("NO");break;
		}
		else if(i==G[0]) puts("YES");
		for(int i=1;i<=tmp[0];i++) fa[tmp[i]]=bl[tmp[i]]=dfn[tmp[i]]=0;
		for(int i=2;i<=cnt;i++) cut[i]=0;
	}
}
/*
7 6 1
1 2
1 3
2 4
2 5
3 6
3 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;
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<<1],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<<1][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());
		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<bits/stdc++.h>
#define N 600050
using namespace std;
int n,m,q;
int bl[N];
int he[N],ne[N<<2],to[N<<2],tot=1;
int a[N],alv,ale;
struct node{int x,y;}ed[N];
inline void addedge(int x,int y){
	to[++tot]=y;ne[tot]=he[x];he[x]=tot;
}
int dfn[N],low[N],cnt,st[N],tp;
inline void tarjan(int g,int fa){
	dfn[g]=low[g]=++cnt;st[++tp]=g;
	for(int i=he[g];i;i=ne[i]){
		if(i==(fa^1))continue;
		if(dfn[to[i]])low[g]=min(low[g],dfn[to[i]]);
		else{
			tarjan(to[i],i);
			low[g]=min(low[g],low[to[i]]);
		}
	}
	if(dfn[g]==low[g]){
		while(1){
			int t=st[tp--];
			bl[t]=g;
			if(t==g)break;
		}
	}
}
int f[N][20];
int L[N],dep[N];
inline bool cmp(const int &a,const int &b){
	return L[a]<L[b];
}
inline void dfs1(int g,int fa){
	dep[g]=dep[fa]+1;
	L[g]=++cnt;f[g][0]=fa;
	for(int i=he[g];i;i=ne[i])
		if(!dep[to[i]])dfs1(to[i],g);
}
inline int LCA(int x,int y){
	if(dep[x]>dep[y])swap(x,y);
	for(int i=18;~i;--i)
		if(dep[f[y][i]]>=dep[x])y=f[y][i];
	if(x==y)return x;
	for(int i=18;~i;--i)
		if(f[x][i]!=f[y][i])x=f[x][i],y=f[y][i];
	return f[x][0];
}
vector<int>v[N];
inline void added(int x,int y){
	if(!x||!y)return;
	v[x].push_back(y);
	v[y].push_back(x);
}
int fr[N];
inline void dfs(int g,int fa){
	dfn[g]=low[g]=++cnt;st[++tp]=g;
	for(int i=0,t,x=0;i<v[g].size();++i){
		t=v[g][i];
		if(!x&&t==fa){x=1;continue;}
		if(dfn[t])low[g]=min(low[g],dfn[t]);
		else dfs(t,g),low[g]=min(low[g],low[t]);
	}
	if(dfn[g]==low[g]){
		while(1){
			int t=st[tp--];
			fr[t]=g;
			if(t==g)break;
		}
	}
}
inline void del(int g){
	dfn[g]=0;
	for(int i=0;i<v[g].size();++i)
		if(dfn[v[g][i]])del(v[g][i]);
	v[g].clear();
}
int pd[N];
inline int work(){
	sort(a+1,a+alv+1,cmp);
	alv=unique(a+1,a+alv+1)-a-1;
	tp=0;
	for(int i=1,d,lca,las;i<=alv;++i){
		d=a[i];
		if(!tp){st[++tp]=d;continue;}
		las=0;lca=LCA(st[tp],d);las=0;
		while(tp&&dep[st[tp]]>dep[lca]){
			added(st[tp],las);
			las=st[tp--];
		}
		added(lca,las);
		if(!tp||st[tp]!=lca)st[++tp]=lca;
		st[++tp]=d;
	}
	--tp;while(tp)added(st[tp],st[tp+1]),--tp;
	for(int i=1;i<=ale;++i)added(ed[i].x,ed[i].y);
	cnt=0;
	for(int i=1;i<=alv;++i)if(!dfn[a[i]])dfs(a[i],0);
	int al=0,ok=1;
	for(int i=1;i<=alv&&!al;++i)if(pd[a[i]])al=fr[a[i]];
//	for(int i=1;i<=alv;++i)printf("fr[%d]=%d\n",a[i],fr[a[i]]);
	for(int i=1;i<=alv&&ok;++i)if(pd[a[i]]&&fr[a[i]]!=al)ok=0;
	puts(ok?"YES":"NO");
	for(int i=1;i<=alv;++i)if(dfn[a[i]])del(a[i]);
	return ok;
}
int R;
inline int rotate(int element){
	element=(element+R)%n;
	if(element==0)element=n;
	return element;
}
int main(){
	scanf("%d%d%d",&n,&m,&q);
	tot=1;
	for(int i=1,x,y;i<=m;++i){
		scanf("%d%d",&x,&y);
		addedge(x,y);addedge(y,x);
		ed[i]=(node){x,y};
	}

	for(int i=1;i<=n;++i)if(!dfn[i])tarjan(i,0);
	for(int i=1;i<=n;++i)he[i]=dfn[i]=0;tot=1;

	for(int i=1;i<=m;++i){
		ed[i].x=bl[ed[i].x];ed[i].y=bl[ed[i].y];
		if(ed[i].x!=ed[i].y)
			addedge(ed[i].x,ed[i].y),addedge(ed[i].y,ed[i].x);
	}

	cnt=0;
	for(int i=1;i<=n;++i)
		if(!dep[bl[i]])dfs1(bl[i],0);

	for(int j=1;j<=18;++j)
		for(int i=1;i<=n;++i)
			f[i][j]=f[f[i][j-1]][j-1];

	for(int i=1;i<=q;++i){
		scanf("%d%d",&alv,&ale);
		for(int j=1;j<=alv;++j)
			scanf("%d",&a[j]),a[j]=rotate(a[j]),a[j]=bl[a[j]],pd[a[j]]=1;
		for(int j=1;j<=ale;++j){
			scanf("%d%d",&ed[j].x,&ed[j].y);
			ed[j].x=rotate(ed[j].x);ed[j].y=rotate(ed[j].y);
			ed[j].x=bl[ed[j].x];ed[j].y=bl[ed[j].y];
			if(ed[j].x==ed[j].y)--j,--ale;
			else a[++alv]=ed[j].x,a[++alv]=ed[j].y;
		}
		if(work())R+=i;
		R%=n;
		for(int j=1;j<=alv;++j)pd[a[j]]=0;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define cri const register int
#define re register
using namespace std;
int dfn[300010],low[300010],bl[300010],obl[300010],in[300010];
int fa[300010],to[600010],la[600010],cnt=1,dcc;
int t[1000010],sta[300010],top,tmp[300010],num,cut[600010];
inline void add(cri x,cri y){
	to[++cnt]=y,la[cnt]=fa[x],fa[x]=cnt;cut[cnt]=0;
	to[++cnt]=x,la[cnt]=fa[y],fa[y]=cnt;cut[cnt]=0;
	//cout<<x<<" link "<<y<<endl;
}
void tj(cri x,cri in){
	dfn[x]=low[x]=++num;//cout<<x<<" "<<dfn[x]<<" "<<fa[x]<<" "<<to[fa[x]]<<endl;
	for(int i=fa[x];i;i=la[i])if(to[i]){
		if(!dfn[to[i]]){
			tj(to[i],i);
			low[x]=min(low[x],low[to[i]]);
			if(low[to[i]]>dfn[x]) cut[i]=cut[i^1]=1;//,cout<<low[to[i]]<<" "<<dfn[x]<<" "<<x<<" cut "<<to[i]<<endl;
		}
		else if(i!=(in^1)) low[x]=min(low[x],dfn[to[i]]);
	}
}
void dfs(cri x,cri ff){
	bl[x]=dcc;
	for(int i=fa[x];i;i=la[i]) if(!bl[to[i]]&&!cut[i]&&to[i]) dfs(to[i],x);
}
int ST[20][600010],bin[600010],dep[300010];
void dfss(cri x,cri ff){
	in[x]=++num;
	//cout<<x<<" "<<in[x]<<endl;
	ST[0][num]=x;dep[x]=dep[ff]+1;
	for(int i=fa[x];i;i=la[i]) if(to[i]!=ff) dfss(to[i],x),ST[0][++num]=x;
}
inline int Min(cri x,cri y){
	return dep[x]<dep[y]?x:y;
}
inline int as(cri x,cri y){
	return in[x]<in[y];
}
inline int lca(int x,int y){
	x=in[x];y=in[y];
	if(x>y) swap(x,y);
	cri b=bin[y-x+1];
	return Min(ST[b][y],ST[b][x+(1<<b)-1]);
}
inline void build(){
	for(int i=2;i<=num;i++) bin[i]=bin[i>>1]+1;
	for(int i=1;i<=num;i++)
		for(int j=1;(1<<j)<=i;j++) ST[j][i]=Min(ST[j-1][i],ST[j-1][i-(1<<j-1)]);
}
inline void insert(cri x){
	if(top==1) return ;
	cri L=lca(x,sta[top]);
	if(L==sta[top]) return ;
	while(top>1&&in[sta[top-1]]>=in[L]) add(sta[top-1],sta[top]),top--;
	if(L!=sta[top]) add(L,sta[top]),sta[top]=L,tmp[++tmp[0]]=L;
}
inline int read(re int a=0,re char ch=getchar()){
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') a=(a<<3)+(a<<1)+(ch^48),ch=getchar();
	return a;
}
int G[300010];
int main(){
	cri n=read(),m=read(),q=read();
	for(int i=1;i<=m;i++) add(read(),read());
	for(int i=1;i<=n;i++) if(!dfn[i]) tj(i,0);
	for(int i=1;i<=n;i++) if(!bl[i]) dcc++,dfs(i,0);
	memset(fa,0,sizeof fa);
	memset(dfn,0,sizeof dfn);
	cnt=num=0;
	for(int i=2;i<=m*2;i+=2) if(bl[to[i]]!=bl[to[i^1]]) add(bl[to[i]],bl[to[i^1]]);
	for(int i=1;i<=dcc;i++) if(!in[i]) add(0,i),dfss(i,0);
	num=0;
	dfss(0,0);
	memset(fa,0,sizeof fa);cnt=1;
	memset(cut,0,sizeof cut);
	build();
	for(int i=1;i<=n;i++) obl[i]=bl[i],bl[i]=0;//puts("");
	for(int T=1;T<=q;T++){
		int ni=read(),mi=read();tmp[0]=G[0]=num=dcc=0;cnt=1;
		for(int i=1;i<=ni;i++) G[++G[0]]=t[i]=obl[read()];//cout<<t[i]<<" ";puts("");
		for(int i=1;i<=mi;i++){
			cri x=obl[read()],y=obl[read()];
			if(x!=y) add(x,y),t[++ni]=x,t[++ni]=y;
		}
		sort(t+1,t+ni+1,as);
		ni=unique(t+1,t+ni+1)-t-1;
		for(int i=1;i<=ni;i++) tmp[++tmp[0]]=t[i];//,cout<<t[i]<<" ";puts("");
		sta[top=1]=t[1];
		for(int i=2;i<=ni;i++) insert(t[i]),sta[++top]=t[i];
		while(top>1) add(sta[top-1],sta[top]),top--;
		for(int i=1;i<=tmp[0];i++) if(!dfn[tmp[i]]) tj(tmp[i],0);//cout<<1<<endl;
		for(int i=1;i<=tmp[0];i++) if(!bl[tmp[i]]) dcc++,dfs(tmp[i],0);
		int is=bl[G[1]];
		for(int i=2;i<=G[0];i++) if(bl[G[i]]!=is){
			puts("NO");break;
		}
		else if(i==G[0]) puts("YES");
		for(int i=1;i<=tmp[0];i++) fa[tmp[i]]=bl[tmp[i]]=dfn[tmp[i]]=0;
		for(int i=2;i<=cnt;i++) cut[i]=0;
	}
}
/*
7 6 1
1 2
1 3
2 4
2 5
3 6
3 7
7 2
1 2 3 4 5 6 7
4 6
5 7

*/


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

int n, m, q;

int p1, p2, p3, p4;
vector < pair <int,int> > graph[1000007];

int l;
int pre[1000007];
int low[1000007];

vector <int> vec;

int bic[1000007];

int b;
vector <int> bgraph[1000007];
int bpre[1000007];
int bpost[1000007];

int c;
int conn[1000007];
int dis[1000007];

vector <int> jump[1000007];

vector <int> subset;
vector < pair <int,int> > edges;

int trans[1000007];
vector <int> sta;

vector < pair <int,int> > ngraph[1000007];
int bic2[1000007];

int res;

void dfs1(int v, int p)
{
    l++;
    pre[v]=l;
    low[v]=l;
    sta.push_back(v);
    for (int i=0; i<graph[v].size(); i++)
    {
        if (graph[v][i].second==p)
        continue;
        if (pre[graph[v][i].first])
        {
            low[v]=min(low[v], pre[graph[v][i].first]);
        }
        else
        {
            dfs1(graph[v][i].first, graph[v][i].second);
            low[v]=min(low[v], low[graph[v][i].first]);
        }
    }
    if (pre[v]==low[v])
    {
        b++;
        while(sta.back()!=v)
        {
            bic[sta.back()]=b;
            sta.pop_back();
        }
        bic[sta.back()]=b;
        sta.pop_back();
    }
}

void dfs2(int v, int p)
{
    l++;
    bpre[v]=l;
    conn[v]=c;

    jump[v].push_back(p);
    while(jump[v].back())
    {
        p1=jump[v].size()-1;
        p2=jump[v].back();
        jump[v].push_back(jump[p2][min(p1, (int)jump[p2].size()-1)]);
    }

    for (int i=0; i<bgraph[v].size(); i++)
    {
        if (bgraph[v][i]!=p)
        {
            dis[bgraph[v][i]]=dis[v]+1;
            dfs2(bgraph[v][i], v);
        }
    }
    l++;
    bpost[v]=l;
}

int lca(int v, int u)
{
    if (conn[v]!=conn[u])
    return 0;
    for (int i=jump[v].size()-1; i>=0; i--)
    {
        if (i<jump[v].size() && dis[jump[v][i]]>=dis[u])
        {
            v=jump[v][i];
        }
    }
    for (int i=jump[u].size()-1; i>=0; i--)
    {
        if (i<jump[u].size() && dis[jump[u][i]]>=dis[v])
        {
            u=jump[u][i];
        }
    }
    for (int i=jump[v].size()-1; i>=0; i--)
    {
        if (i<jump[v].size() && i<jump[u].size() && jump[v][i]!=jump[u][i])
        {
            v=jump[v][i];
            u=jump[u][i];
        }
    }
    if (v!=u)
    v=jump[v][0];
    return v;
}

bool comp(int v, int u)
{
    return bpre[v]<bpre[u];
}

void filtr()
{
    vector <int> vec2=vec;
    vec.clear();
    sort(vec2.begin(), vec2.end(), comp);
    for (int i=0; i<vec2.size(); i++)
    {
        if (!vec2[i])
        continue;
        if (!i || vec2[i]!=vec2[i-1])
        {
            vec.push_back(vec2[i]);
        }
    }
}

void dfs3(int v, int p)
{
    l++;
    pre[v]=l;
    low[v]=l;
    sta.push_back(v);
    for (int i=0; i<ngraph[v].size(); i++)
    {
        if (ngraph[v][i].second==p)
        continue;
        if (pre[ngraph[v][i].first])
        {
            low[v]=min(low[v], pre[ngraph[v][i].first]);
        }
        else
        {
            dfs3(ngraph[v][i].first, ngraph[v][i].second);
            low[v]=min(low[v], low[ngraph[v][i].first]);
        }
    }
    if (pre[v]==low[v])
    {
        b++;
        while(sta.back()!=v)
        {
            bic2[sta.back()]=b;
            sta.pop_back();
        }
        bic2[sta.back()]=b;
        sta.pop_back();
    }
}

long long R;

int rotate(int element)
{
    element=(element+R)%n;
    if (element==0)
    element=n;
    return element;
}

int main()
{
    scanf("%d%d%d", &n, &m, &q);
    for (int i=1; i<=m; i++)
    {
        scanf("%d%d", &p1, &p2);
        graph[p1].push_back(make_pair(p2, i));
        graph[p2].push_back(make_pair(p1, i));
    }
    for (int i=1; i<=n; i++)
    {
        if (!pre[i])
        {
            dfs1(i, 0);
        }
    }
    for (int i=1; i<=n; i++)
    {
        for (int j=0; j<graph[i].size(); j++)
        {
            if (bic[i]!=bic[graph[i][j].first])
            {
                bgraph[bic[i]].push_back(bic[graph[i][j].first]);
            }
        }
    }
    l=0;
    for (int i=1; i<=b; i++)
    {
        if (!bpre[i])
        {
            c++;
            dfs2(i, 0);
        }
    }
    for (int h=1; h<=q; h++)
    {
        subset.clear();
        edges.clear();
        vec.clear();
        scanf("%d%d", &p1, &p2);
        while(p1--)
        {
            scanf("%d", &p3);
            p3=rotate(p3);
            subset.push_back(bic[p3]);
            vec.push_back(bic[p3]);
        }
        while(p2--)
        {
            scanf("%d%d", &p3, &p4);
            p3=rotate(p3);
            p4=rotate(p4);
            edges.push_back(make_pair(bic[p3], bic[p4]));
            vec.push_back(bic[p3]);
            vec.push_back(bic[p4]);
        }
        sort(vec.begin(), vec.end(), comp);
        for (int i=vec.size()-1; i; i--)
        {
            vec.push_back(lca(vec[i], vec[i-1]));
        }
        filtr();
        c=vec.size();
        for (int i=0; i<c; i++)
        {
            trans[vec[i]]=i+1;
            ngraph[i+1].clear();
            pre[i+1]=0;
            low[i+1]=0;
        }
        l=0;
        sta.clear();
        for (int i=0; i<c; i++)
        {
            while(!sta.empty() && bpost[vec[i]]>bpost[sta.back()])
            {
                sta.pop_back();
            }
            if (!sta.empty())
            {
                l++;
                ngraph[trans[vec[i]]].push_back(make_pair(trans[sta.back()], l));
                ngraph[trans[sta.back()]].push_back(make_pair(trans[vec[i]], l));
            }
            sta.push_back(vec[i]);
        }
        sta.clear();
        for (int i=0; i<edges.size(); i++)
        {
            l++;
            ngraph[trans[edges[i].first]].push_back(make_pair(trans[edges[i].second], l));
            ngraph[trans[edges[i].second]].push_back(make_pair(trans[edges[i].first], l));
        }
        b=0;
        l=0;
        for (int i=1; i<=c; i++)
        {
            if (!pre[i])
            {
                dfs3(i, 0);
            }
        }
        res=1;
        for (int i=1; i<subset.size(); i++)
        {
            if (bic2[trans[subset[i]]]!=bic2[trans[subset[0]]])
            {
                res=0;
            }
        }
        if (res)
        {
            printf("YES\n");
            R+=h;
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}


#include <bits/stdc++.h>

const int N = 300005;

int n, m, q, tot = 1, head[N];
struct edge { int to, nxt; } e[N << 1];

void link(int x, int y) {
	e[++tot] = (edge) { y, head[x] }, head[x] = tot;
	e[++tot] = (edge) { x, head[y] }, head[y] = tot;
}
struct tarjan {
	int dfn[N], low[N], bel[N], scc, clk, stack[N], top;
	void _tarjan(int x, int f = 0) {
		dfn[x] = low[x] = ++clk, stack[++top] = x;
		for (int i = head[x]; i; i = e[i].nxt) if (i ^ f ^ 1)
			if (!dfn[e[i].to])
				_tarjan(e[i].to, i), low[x] = std::min(low[e[i].to], low[x]);
			else
				low[x] = std::min(low[x], dfn[e[i].to]);
		if (low[x] == dfn[x]) {
			int v; ++scc;
			do bel[v = stack[top--]] = scc; while (v != x);
		}
	}
	void solve() {
		for (int i = 1; i <= n; ++i) if (!dfn[i]) _tarjan(i);
	}
	void solve(const std::vector<int> &points) {
		scc = clk = 0;
		for (int p : points) dfn[p] = 0;
		for (int p : points) if (!dfn[p]) _tarjan(p);
	}
} A, B;

int st[19][N], dfn[N], out[N], idx, cnt, id[N];
void dfs(int x, int f = 0) {
	st[0][idx] = f, dfn[x] = ++idx, id[x] = cnt;
	for (int i = head[x]; i; i = e[i].nxt)
		if (e[i].to != f) dfs(e[i].to, x);
	out[x] = idx;
}
int _min(int x, int y) { return dfn[x] < dfn[y] ? x : y; }
void init() {
	for (int i = 1; i < 19; ++i)
		for (int j = 1; j <= n - (1 << i); ++j)
			st[i][j] = _min(st[i - 1][j], st[i - 1][j + (1 << i - 1)]);
}
int lca(int x, int y) {
	if (x == y) return x;
	if (dfn[x] > dfn[y]) std::swap(x, y);
	int k = 31 - __builtin_clz(dfn[y] - dfn[x]);
	return _min(st[k][dfn[x]], st[k][dfn[y] - (1 << k)]);
}
bool in_subtree(int x, int y) {
	return dfn[x] >= dfn[y] && dfn[x] <= out[y];
}

int R = 0;
int rotate(int x) {
	x = (x + R) % n;
	return x ?: n;
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m >> q;
	static int l[N], r[N];
	for (int i = 0; i < m; ++i)
		std::cin >> l[i] >> r[i], link(l[i], r[i]);
	A.solve();
	std::memset(head, 0, sizeof head), tot = 1;
	for (int i = 0; i < m; ++i)
		if (A.bel[l[i]] != A.bel[r[i]]) link(A.bel[l[i]], A.bel[r[i]]);
	for (int i = 1; i <= A.scc; ++i) if (!id[i]) ++cnt, dfs(i);
	init();
	std::memset(head, 0, sizeof head), tot = 1;
	for (int i = 0; i < q; ++i) {
		auto cmp = [&] (int x, int y) { return dfn[x] < dfn[y]; };
		int _n, _m; std::cin >> _n >> _m;
		static int a[N];
		std::vector<int> p(_n);
		for (int j = 0, x; j < _n; ++j)
			std::cin >> p[j], p[j] = A.bel[rotate(p[j])], a[j] = p[j];
		for (int j = 0, x, y; j < _m; ++j) {
			std::cin >> l[j] >> r[j], l[j] = A.bel[rotate(l[j])], r[j] = A.bel[rotate(r[j])];
			link(l[j], r[j]), p.emplace_back(l[j]), p.emplace_back(r[j]);
		}
		std::sort(p.begin(), p.end(), cmp), p.resize(std::unique(p.begin(), p.end()) - p.begin());
		int t = p.size();
		for (int j = 1; j < t; ++j) if (id[p[j]] == id[p[j - 1]])
			p.emplace_back(lca(p[j], p[j - 1]));
		std::sort(p.begin(), p.end(), cmp), p.resize(std::unique(p.begin(), p.end()) - p.begin());
		static int stack[N], top; top = 0;
		for (int j = 0; j < p.size(); ++j) {
			if (!j || id[p[j]] != id[p[j - 1]]) {
				stack[top = 1] = p[j];
			} else {
				while (!in_subtree(p[j], stack[top])) --top;
				if (top) link(p[j], stack[top]);
				stack[++top] = p[j];
			}
		}
		B.solve(p);
		bool flag = 1;
		for (int j = 1; j < _n; ++j)
			if (B.bel[a[j]] != B.bel[a[0]])
				{flag = 0; break;}
		std::cout << (flag ? "YES" : "NO") << '\n';
		if (flag) R = (R + i + 1) % n;
		for (int j : p) head[j] = 0; tot = 1;
	}
	return 0;
}