#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 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[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[l[j]], r[j] = A.bel[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());
		for (int j = 1; j < p.size(); ++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';
		for (int j : p) head[j] = 0; tot = 1;
	}
	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());
		for (int j = 1; j < p.size(); ++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;
}


#include<stdio.h>
#include<map>
#include<algorithm>
#define N 300005
using namespace std;
map<int,int>have[N];
int u[N],v[N],S[N],U[N*3];
int n,m,i,ans,x,y,Q,ni,mi,q;
int get(int *f,int u){return f[u]==u?u:f[u]=get(f,f[u]);}
struct Tree{
	int Go[N<<1],Next[N<<1],End[N],cnt,num;
	int vis[N],f[N][19],deep[N],dfn[N],tot;
	void add(int u,int v){Go[++cnt]=v;Next[cnt]=End[u];End[u]=cnt;}
	void DFS(int x){
		vis[x]=num;dfn[x]=++tot;
		for (int i=1;i<=18;i++)
			f[x][i]=f[f[x][i-1]][i-1];
		for (int i=End[x],y;i;i=Next[i])
			if (!vis[y=Go[i]])
				f[y][0]=x,deep[y]=deep[x]+1,DFS(y);
  }
  int LCA(int x,int y){
  	if (deep[x]<deep[y]) swap(x,y);
  	int d=deep[x]-deep[y];
  	for (int i=0;i<=18;i++)
  		if ((d>>i)&1) x=f[x][i];
  	if (x==y) return x;
  	for (int i=18;i>=0;i--)
  		if (f[x][i]!=f[y][i])
  		  x=f[x][i],y=f[y][i];
  	return f[x][0];
  }
}T;
struct Graph{
	int Q[N],vis[N],low[N],dfn[N],id[N];
	int Go[N<<1],End[N],Next[N<<1];
	int n,Case,step,cnt;
	Graph(){Case=cnt=1;}
	void Push(int v){if (vis[v]!=Case) vis[v]=Case,Q[++*Q]=v;}
	void add(int u,int v){
		Go[++cnt]=v;Next[cnt]=End[u];End[u]=cnt;
		Push(u);Push(v);
	}
	void clear(){
		for (int i=1;i<=*Q;i++)
			low[Q[i]]=dfn[Q[i]]=End[Q[i]]=0;
		cnt=1;step=*Q=0;++Case;
	}
	void DFS(int x,int Fa){
		low[x]=dfn[x]=++step;
		for (int i=End[x],y;i;i=Next[i]){
			if ((y=Go[i])==Fa) {Fa=-1;continue;}
			if (dfn[y]) {low[x]=min(low[x],dfn[y]);continue;}
			DFS(y,x);low[x]=min(low[x],low[y]);
			if (low[y]<=dfn[x]) id[get(id,y)]=get(id,x);
	  }
  }
	void tarjan(){
		for (int i=1;i<=*Q;i++) id[Q[i]]=Q[i];
		for (int i=1;i<=*Q;i++)
			if (!dfn[Q[i]])
        DFS(Q[i],0);
		for (int i=1;i<=*Q;i++) get(id,Q[i]);
  }
}G,H;
void key(int &x){x+=ans;x%=n;if (!x) x=n;}
inline int cmp(const int &A,const int &B){return T.dfn[A]<T.dfn[B];}
int main(){
	scanf("%d%d%d",&n,&m,&Q);
	for (i=1;i<=m;i++)
		scanf("%d%d",&x,&y),G.add(x,y),G.add(y,x);
	for (i=1;i<=n;i++) G.Push(i);G.tarjan();
	for (i=2;i<=G.cnt;i+=2){
		x=G.id[G.Go[i]];y=G.id[G.Go[i^1]];
		if (x==y) continue;if (x>y) swap(x,y);
		if (have[x].find(y)!=have[x].end()) continue;
		have[x][y]=1;T.add(x,y);T.add(y,x);
  }
	for (i=1;i<=n;i++)
		if (G.id[i]==i&&!T.vis[i])
			++T.num,T.DFS(i);
	for (q=1;q<=Q;q++){
		scanf("%d%d",&ni,&mi);*U=0;
		for (i=1;i<=ni;i++)
			scanf("%d",&S[i]),key(S[i]),S[i]=U[++*U]=G.id[S[i]];
		for (i=1;i<=mi;i++){
			scanf("%d%d",&u[i],&v[i]);key(u[i]),key(v[i]);
			u[i]=U[++*U]=G.id[u[i]],v[i]=U[++*U]=G.id[v[i]];
	  }sort(U+1,U+*U+1,cmp);
		x=*U=unique(U+1,U+*U+1)-(U+1);
		for (i=1;i<x;i++)
			if (T.vis[U[i]]==T.vis[U[i+1]])
				U[++*U]=T.LCA(U[i],U[i+1]);
		sort(U+1,U+*U+1,cmp);
		*U=unique(U+1,U+*U+1)-(U+1);
		for (i=1;i<=*U;i++) H.Push(U[i]);
		for (i=2;i<=*U;i++)
			if (T.vis[U[i]]==T.vis[U[i-1]])
				x=T.LCA(U[i-1],U[i]),H.add(x,U[i]),H.add(U[i],x);
		for (i=1;i<=mi;i++)
			if (u[i]!=v[i])
 				H.add(u[i],v[i]),H.add(v[i],u[i]);
		H.tarjan();
		for (i=1;i<ni;i++)
			if (H.id[S[i]]!=H.id[S[i+1]]) break;
		if (i==ni) puts("YES"),ans+=q,ans%=n;else puts("NO");
		H.clear();
  }
}


/*
Problem :
Algorithm :
Status :
*/
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define DEBUG cerr << "Passing Line " << __LINE__<< " in Function [" << __FUNCTION__ << "].\n";
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const ll llINF = 1e18;
const int MAXN = 6e5 + 5;
const int LOG = 20;

namespace FastIO{
    char buf[1 << 23],*p1 = buf,*p2 = buf;

    #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,1 << 21,stdin),p1 == p2) ? EOF : *p1++)

    inline int read() {
        static int x,f;
        static char ch;
        x = 0,f = 1;
        ch = getchar();
        while(!isdigit(ch)){
            if(ch == '-')
                f = -1;
            ch = getchar();
        }
        while(isdigit(ch)){
            x = (x << 1) + (x << 3) + (ch ^ 48);
            ch = getchar();
        }
        return x * f;
    }

    inline ll readll() {
        static ll x = 0;
        static int f;
        static char ch;
        x = 0,f = 1;
        ch = getchar();
        while(!isdigit(ch)){
            if(ch == '-')
                f = -1;
            ch = getchar();
        }
        while(isdigit(ch)){
            x = (x << 1) + (x << 3) + (ch ^ 48);
            ch = getchar();
        }
        return x * f;
    }

    void write(int x){
        if(!x)
            putchar('0');
        if(x < 0){
            x = -x;
            putchar('-');
        }
        static int sta[20];
        int tot = 0;
        while(x){
            sta[tot++] = x % 10;
            x /= 10;
        }
        while(tot)
            putchar(sta[--tot] + 48);
    }
}

using FastIO::read;
using FastIO::readll;
using FastIO::write;

int n,Q,len = 1,tot,m,dcc,cnt,R;
int head[MAXN],dfn[MAXN],low[MAXN],isbridge[MAXN],f[MAXN][LOG];
int belong[MAXN],tim[MAXN],dep[MAXN],root[MAXN],bel[MAXN];
vector<int> bridges;
vector<int> G[MAXN];

struct Edge{
    int to,next;
} e[MAXN << 1];

void add(int u,int v){
    e[++len].to = v;
    e[len].next = head[u];
    head[u] = len;
}

void addedge(int u,int v){
    add(u,v);
    add(v,u);
}

void tarjan(int u,int fa){
    dfn[u] = low[u] = ++tot;
    for(int i = head[u];i != -1;i = e[i].next){
    	if(i == (fa ^ 1))
    		continue;
        int v = e[i].to;
        if(!dfn[v]){
            tarjan(v,i);
            low[u] = min(low[u],low[v]);
            if(low[v] > dfn[u]){
                isbridge[i] = isbridge[i ^ 1] = 1;
                bridges.push_back(i);
            }
        }else
            low[u] = min(low[u],dfn[v]);
    }
}

void dfs1(int u){
    belong[u] = dcc;
    for(int i = head[u];i != -1;i = e[i].next){
        int v = e[i].to;
        if(belong[v] || isbridge[i])
            continue;
        dfs1(v);
    }
}

void dfs2(int u,int fa){
    tim[u] = ++cnt;
    f[u][0] = fa;
    dep[u] = dep[fa] + 1;
    for(int i = 1;i < LOG;i++)
        f[u][i] = f[f[u][i - 1]][i - 1];
    for(int i = 0;i < (int)G[u].size();i++){
        int v = G[u][i];
        if(v == fa)
            continue;
        root[v] = root[u];
        dfs2(v,u);
    }
}

void Init(){
    for(int i = 1;i <= n;i++){
        if(!dfn[i])
            tarjan(i,0);
    }
    for(int i = 1;i <= n;i++){
        if(!belong[i]){
            dcc += 1;
            dfs1(i);
        }
    }
    for(int i = 2;i <= len;i++){
        if(isbridge[i])
            G[belong[e[i].to]].push_back(belong[e[i ^ 1].to]);
    }
    for(int i = 1;i <= dcc;i++){
        if(!root[i]){
            root[i] = i;
            dfs2(i,0);
        }
    }
    for(int i = 1;i <= n;i++)
        bel[i] = belong[i];
    len = 1;
    tot = dcc = 0;
    memset(head,-1,sizeof(head));
    memset(belong,0,sizeof(belong));
    memset(dfn,0,sizeof(dfn));
    memset(low,0,sizeof(low));
    memset(isbridge,0,sizeof(isbridge));
}

int LCA(int u,int v){
    if(dep[u] < dep[v])
        swap(u,v);
    for(int i = LOG - 1;i >= 0;i--){
        if(dep[f[u][i]] >= dep[v])
            u = f[u][i];
    }
    if(u == v)
        return u;
    for(int i = LOG - 1;i >= 0;i--){
        if(f[u][i] != f[v][i]){
            u = f[u][i];
            v = f[v][i];
        }
    }
    return f[u][0];
}

bool cmp(const int &x,const int &y){
    return tim[x] < tim[y];
}

void BuildTree(vector<int> &vec){
    sort(vec.begin(),vec.end(),cmp);
    static int st[MAXN];
    static int top,curRoot;
    static vector<int> res;
    top = curRoot = 0;
    res = vec;
    for(int i = 0;i < (int)vec.size();i++){
        int u = vec[i];
        if(top && root[u] != curRoot){
            top -= 1;
            while(top){
                addedge(st[top + 1],st[top]);
                top -= 1;
            }
        }
        int lca = LCA(u,st[top]);
        if(lca != st[top]){
            while(top && tim[st[top - 1]] >= tim[lca]){
                addedge(st[top - 1],st[top]);
                top -= 1;
            }
            if(st[top] != lca){
                addedge(st[top],lca);
                st[top] = lca;
                res.push_back(lca);
            }
        }
        st[++top] = u;
        curRoot = root[u];
    }
    while(top > 1){
        addedge(st[top],st[top - 1]);
        top -= 1;
    }
    vec = res;
}

void Rotate(int &x){
    x += R;
    if(x > n)
        x -= n;
}

void Getedcc(const vector<int> &vec){
    for(int i = 0;i < (int)vec.size();i++){
        int u = vec[i];
        if(!dfn[u])
            tarjan(u,0);
    }
    for(int i = 0;i < (int)vec.size();i++){
        int u = vec[i];
        if(!belong[u]){
            dcc += 1;
            dfs1(u);
        }
    }
}

void Clear(const vector<int> &vec){
    len = 1;
    tot = dcc = 0;
    for(int i = 0;i < (int)vec.size();i++){
        int u = vec[i];
        head[u] = -1;
        dfn[u] = low[u] = belong[u] = 0;
    }
    for(int i = 0;i < (int)bridges.size();i++)
        isbridge[bridges[i]] = isbridge[bridges[i] ^ 1] = 0;
    bridges.clear();
}

int main(){
    // freopen("data.in","r",stdin);
    // freopen("data.out","w",stdout);
    memset(head,-1,sizeof(head));
    n = read(); m = read(); Q = read();
    for(int i = 1;i <= m;i++){
        int u = read(),v = read();
        addedge(u,v);
    }
    Init();
    for(int q = 1;q <= Q;q++){
        int ni = read(),mi = read();
        vector<pii> edges;
        vector<int> vec,nodes;
        edges.clear();
        vec.clear();
        nodes.clear();
        for(int i = 1;i <= ni;i++){
            int x = read();
            Rotate(x);
            x = bel[x];
            vec.push_back(x);
            nodes.push_back(x);
        }
        for(int i = 1;i <= mi;i++){
            int x = read(),y = read();
            Rotate(x);
            Rotate(y);
            x = bel[x];
            y = bel[y];
            if(x == y)
                continue;
            edges.push_back(make_pair(x,y));
            nodes.push_back(x);
            nodes.push_back(y);
        }
        sort(nodes.begin(),nodes.end());
        nodes.erase(unique(nodes.begin(),nodes.end()),nodes.end());
        BuildTree(nodes);
        for(int i = 0;i < (int)edges.size();i++)
            addedge(edges[i].first,edges[i].second);
        Getedcc(nodes);
        int id = belong[vec[0]];
        int flag = 1;
        for(int i = 1;i < (int)vec.size();i++){
            if(belong[vec[i]] != id){
                flag = 0;
                break;
            }
        }
        if(flag)
            puts("YES");
        else
            puts("NO");
        if(flag)
            R = (R + q) % n;
        Clear(nodes);
    }
    return 0;
}


/*
Problem :
Algorithm :
Status :
*/
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define DEBUG cerr << "Passing Line " << __LINE__<< " in Function [" << __FUNCTION__ << "].\n";
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const ll llINF = 1e18;
const int MAXN = 3e5 + 5;
const int LOG = 20;

namespace FastIO{
    char buf[1 << 23],*p1 = buf,*p2 = buf;

    #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,1 << 21,stdin),p1 == p2) ? EOF : *p1++)

    inline int read() {
        static int x,f;
        static char ch;
        x = 0,f = 1;
        ch = getchar();
        while(!isdigit(ch)){
            if(ch == '-')
                f = -1;
            ch = getchar();
        }
        while(isdigit(ch)){
            x = (x << 1) + (x << 3) + (ch ^ 48);
            ch = getchar();
        }
        return x * f;
    }

    inline ll readll() {
        static ll x = 0;
        static int f;
        static char ch;
        x = 0,f = 1;
        ch = getchar();
        while(!isdigit(ch)){
            if(ch == '-')
                f = -1;
            ch = getchar();
        }
        while(isdigit(ch)){
            x = (x << 1) + (x << 3) + (ch ^ 48);
            ch = getchar();
        }
        return x * f;
    }

    void write(int x){
        if(!x)
            putchar('0');
        if(x < 0){
            x = -x;
            putchar('-');
        }
        static int sta[20];
        int tot = 0;
        while(x){
            sta[tot++] = x % 10;
            x /= 10;
        }
        while(tot)
            putchar(sta[--tot] + 48);
    }
}

using FastIO::read;
using FastIO::readll;
using FastIO::write;

int n,Q,len = 1,tot,m,dcc,cnt,R;
int head[MAXN],dfn[MAXN],low[MAXN],isbridge[MAXN],f[MAXN][LOG];
int belong[MAXN],tim[MAXN],dep[MAXN],root[MAXN],bel[MAXN];
vector<int> bridges;
vector<int> G[MAXN];

struct Edge{
    int to,next;
} e[MAXN << 1];

void add(int u,int v){
    e[++len].to = v;
    e[len].next = head[u];
    head[u] = len;
}

void addedge(int u,int v){
    add(u,v);
    add(v,u);
}

void tarjan(int u,int fa){
    dfn[u] = low[u] = ++tot;
    for(int i = head[u];i != -1;i = e[i].next){
        int v = e[i].to;
        if(v == fa)
            continue;
        if(!dfn[v]){
            tarjan(v,u);
            low[u] = min(low[u],low[v]);
            if(low[v] > dfn[u]){
                isbridge[i] = isbridge[i ^ 1] = 1;
                bridges.push_back(i);
            }
        }else
            low[u] = min(low[u],dfn[v]);
    }
}

void dfs1(int u){
    belong[u] = dcc;
    for(int i = head[u];i != -1;i = e[i].next){
        int v = e[i].to;
        if(belong[v] || isbridge[i])
            continue;
        dfs1(v);
    }
}

void dfs2(int u,int fa){
    tim[u] = ++cnt;
    f[u][0] = fa;
    dep[u] = dep[fa] + 1;
    for(int i = 1;i < LOG;i++)
        f[u][i] = f[f[u][i - 1]][i - 1];
    for(int i = 0;i < (int)G[u].size();i++){
        int v = G[u][i];
        if(v == fa)
            continue;
        root[v] = root[u];
        dfs2(v,u);
    }
}

void Init(){
    for(int i = 1;i <= n;i++){
        if(!dfn[i])
            tarjan(i,0);
    }
    for(int i = 1;i <= n;i++){
        if(!belong[i]){
            dcc += 1;
            dfs1(i);
        }
    }
    for(int i = 2;i <= len;i++){
        if(isbridge[i])
            G[belong[e[i].to]].push_back(belong[e[i ^ 1].to]);
    }
    for(int i = 1;i <= dcc;i++){
        if(!root[i]){
            root[i] = i;
            dfs2(i,0);
        }
    }
    for(int i = 1;i <= n;i++)
        bel[i] = belong[i];
    len = 1;
    tot = dcc = 0;
    memset(head,-1,sizeof(head));
    memset(belong,0,sizeof(belong));
    memset(dfn,0,sizeof(dfn));
    memset(low,0,sizeof(low));
    memset(isbridge,0,sizeof(isbridge));
}

int LCA(int u,int v){
    if(dep[u] < dep[v])
        swap(u,v);
    for(int i = LOG - 1;i >= 0;i--){
        if(dep[f[u][i]] >= dep[v])
            u = f[u][i];
    }
    if(u == v)
        return u;
    for(int i = LOG - 1;i >= 0;i--){
        if(f[u][i] != f[v][i]){
            u = f[u][i];
            v = f[v][i];
        }
    }
    return f[u][0];
}

bool cmp(const int &x,const int &y){
    return tim[x] < tim[y];
}

void BuildTree(vector<int> &vec){
    sort(vec.begin(),vec.end(),cmp);
    static int st[MAXN];
    static int top,curRoot;
    static vector<int> res;
    top = curRoot = 0;
    res = vec;
    for(int i = 0;i < (int)vec.size();i++){
        int u = vec[i];
        if(top && root[u] != curRoot){
            top -= 1;
            while(top){
                addedge(st[top + 1],st[top]);
                top -= 1;
            }
        }
        int lca = LCA(u,st[top]);
        if(lca != st[top]){
            while(top && tim[st[top - 1]] >= tim[lca]){
                addedge(st[top - 1],st[top]);
                top -= 1;
            }
            if(st[top] != lca){
                addedge(st[top],lca);
                st[top] = lca;
                res.push_back(lca);
            }
        }
        st[++top] = u;
        curRoot = root[u];
    }
    while(top > 1){
        addedge(st[top],st[top - 1]);
        top -= 1;
    }
    vec = res;
}

void Rotate(int &x){
    x += R;
    if(x > n)
        x -= n;
}

void Getedcc(const vector<int> &vec){
    for(int i = 0;i < (int)vec.size();i++){
        int u = vec[i];
        if(!dfn[u])
            tarjan(u,0);
    }
    for(int i = 0;i < (int)vec.size();i++){
        int u = vec[i];
        if(!belong[u]){
            dcc += 1;
            dfs1(u);
        }
    }
}

void Clear(const vector<int> &vec){
    len = 1;
    tot = dcc = 0;
    for(int i = 0;i < (int)vec.size();i++){
        int u = vec[i];
        head[u] = -1;
        dfn[u] = low[u] = belong[u] = 0;
    }
    for(int i = 0;i < (int)bridges.size();i++)
        isbridge[bridges[i]] = isbridge[bridges[i] ^ 1] = 0;
    bridges.clear();
}

int main(){
    // freopen("data.in","r",stdin);
    // freopen("data.out","w",stdout);
    memset(head,-1,sizeof(head));
    n = read(); m = read(); Q = read();
    for(int i = 1;i <= m;i++){
        int u = read(),v = read();
        addedge(u,v);
    }
    Init();
    for(int q = 1;q <= Q;q++){
        int ni = read(),mi = read();
        vector<pii> edges;
        vector<int> vec,nodes;
        edges.clear();
        vec.clear();
        nodes.clear();
        for(int i = 1;i <= ni;i++){
            int x = read();
            Rotate(x);
            x = bel[x];
            vec.push_back(x);
            nodes.push_back(x);
        }
        for(int i = 1;i <= mi;i++){
            int x = read(),y = read();
            Rotate(x);
            Rotate(y);
            x = bel[x];
            y = bel[y];
            if(x == y)
                continue;
            edges.push_back(make_pair(x,y));
            nodes.push_back(x);
            nodes.push_back(y);
        }
        sort(nodes.begin(),nodes.end());
        nodes.erase(unique(nodes.begin(),nodes.end()),nodes.end());
        BuildTree(nodes);
        for(int i = 0;i < (int)edges.size();i++)
            addedge(edges[i].first,edges[i].second);
        Getedcc(nodes);
        int id = belong[vec[0]];
        int flag = 1;
        for(int i = 1;i < (int)vec.size();i++){
            if(belong[vec[i]] != id){
                flag = 0;
                break;
            }
        }
        if(flag)
            puts("YES");
        else
            puts("NO");
        if(flag)
            R = (R + q) % n;
        Clear(nodes);
    }
    return 0;
}


/*
Problem :
Algorithm :
Status :
*/
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define DEBUG cerr << "Passing Line " << __LINE__<< " in Function [" << __FUNCTION__ << "].\n";
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const ll llINF = 1e18;
const int MAXN = 3e5 + 5;
const int LOG = 20;

namespace FastIO{
    char buf[1 << 23],*p1 = buf,*p2 = buf;

    #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,1 << 21,stdin),p1 == p2) ? EOF : *p1++)

    inline int read() {
        static int x,f;
        static char ch;
        x = 0,f = 1;
        ch = getchar();
        while(!isdigit(ch)){
            if(ch == '-')
                f = -1;
            ch = getchar();
        }
        while(isdigit(ch)){
            x = (x << 1) + (x << 3) + (ch ^ 48);
            ch = getchar();
        }
        return x * f;
    }

    inline ll readll() {
        static ll x = 0;
        static int f;
        static char ch;
        x = 0,f = 1;
        ch = getchar();
        while(!isdigit(ch)){
            if(ch == '-')
                f = -1;
            ch = getchar();
        }
        while(isdigit(ch)){
            x = (x << 1) + (x << 3) + (ch ^ 48);
            ch = getchar();
        }
        return x * f;
    }

    void write(int x){
        if(!x)
            putchar('0');
        if(x < 0){
            x = -x;
            putchar('-');
        }
        static int sta[20];
        int tot = 0;
        while(x){
            sta[tot++] = x % 10;
            x /= 10;
        }
        while(tot)
            putchar(sta[--tot] + 48);
    }
}

using FastIO::read;
using FastIO::readll;
using FastIO::write;

int n,Q,len = 1,tot,m,dcc,cnt,R;
int head[MAXN],dfn[MAXN],low[MAXN],isbridge[MAXN],f[MAXN][LOG];
int belong[MAXN],tim[MAXN],dep[MAXN],root[MAXN],bel[MAXN];
vector<int> bridges;
vector<int> G[MAXN];

struct Edge{
    int to,next;
} e[MAXN << 1];

void add(int u,int v){
    e[++len].to = v;
    e[len].next = head[u];
    head[u] = len;
}

void addedge(int u,int v){
    add(u,v);
    add(v,u);
}

void tarjan(int u,int fa){
    dfn[u] = low[u] = ++tot;
    for(int i = head[u];i != -1;i = e[i].next){
    	if(i == (fa ^ 1))
    		continue;
        int v = e[i].to;
        if(!dfn[v]){
            tarjan(v,i);
            low[u] = min(low[u],low[v]);
            if(low[v] > dfn[u]){
                isbridge[i] = isbridge[i ^ 1] = 1;
                bridges.push_back(i);
            }
        }else
            low[u] = min(low[u],dfn[v]);
    }
}

void dfs1(int u){
    belong[u] = dcc;
    for(int i = head[u];i != -1;i = e[i].next){
        int v = e[i].to;
        if(belong[v] || isbridge[i])
            continue;
        dfs1(v);
    }
}

void dfs2(int u,int fa){
    tim[u] = ++cnt;
    f[u][0] = fa;
    dep[u] = dep[fa] + 1;
    for(int i = 1;i < LOG;i++)
        f[u][i] = f[f[u][i - 1]][i - 1];
    for(int i = 0;i < (int)G[u].size();i++){
        int v = G[u][i];
        if(v == fa)
            continue;
        root[v] = root[u];
        dfs2(v,u);
    }
}

void Init(){
    for(int i = 1;i <= n;i++){
        if(!dfn[i])
            tarjan(i,0);
    }
    for(int i = 1;i <= n;i++){
        if(!belong[i]){
            dcc += 1;
            dfs1(i);
        }
    }
    for(int i = 2;i <= len;i++){
        if(isbridge[i])
            G[belong[e[i].to]].push_back(belong[e[i ^ 1].to]);
    }
    for(int i = 1;i <= dcc;i++){
        if(!root[i]){
            root[i] = i;
            dfs2(i,0);
        }
    }
    for(int i = 1;i <= n;i++)
        bel[i] = belong[i];
    len = 1;
    tot = dcc = 0;
    memset(head,-1,sizeof(head));
    memset(belong,0,sizeof(belong));
    memset(dfn,0,sizeof(dfn));
    memset(low,0,sizeof(low));
    memset(isbridge,0,sizeof(isbridge));
}

int LCA(int u,int v){
    if(dep[u] < dep[v])
        swap(u,v);
    for(int i = LOG - 1;i >= 0;i--){
        if(dep[f[u][i]] >= dep[v])
            u = f[u][i];
    }
    if(u == v)
        return u;
    for(int i = LOG - 1;i >= 0;i--){
        if(f[u][i] != f[v][i]){
            u = f[u][i];
            v = f[v][i];
        }
    }
    return f[u][0];
}

bool cmp(const int &x,const int &y){
    return tim[x] < tim[y];
}

void BuildTree(vector<int> &vec){
    sort(vec.begin(),vec.end(),cmp);
    static int st[MAXN];
    static int top,curRoot;
    static vector<int> res;
    top = curRoot = 0;
    res = vec;
    for(int i = 0;i < (int)vec.size();i++){
        int u = vec[i];
        if(top && root[u] != curRoot){
            top -= 1;
            while(top){
                addedge(st[top + 1],st[top]);
                top -= 1;
            }
        }
        int lca = LCA(u,st[top]);
        if(lca != st[top]){
            while(top && tim[st[top - 1]] >= tim[lca]){
                addedge(st[top - 1],st[top]);
                top -= 1;
            }
            if(st[top] != lca){
                addedge(st[top],lca);
                st[top] = lca;
                res.push_back(lca);
            }
        }
        st[++top] = u;
        curRoot = root[u];
    }
    while(top > 1){
        addedge(st[top],st[top - 1]);
        top -= 1;
    }
    vec = res;
}

void Rotate(int &x){
    x += R;
    if(x > n)
        x -= n;
}

void Getedcc(const vector<int> &vec){
    for(int i = 0;i < (int)vec.size();i++){
        int u = vec[i];
        if(!dfn[u])
            tarjan(u,0);
    }
    for(int i = 0;i < (int)vec.size();i++){
        int u = vec[i];
        if(!belong[u]){
            dcc += 1;
            dfs1(u);
        }
    }
}

void Clear(const vector<int> &vec){
    len = 1;
    tot = dcc = 0;
    for(int i = 0;i < (int)vec.size();i++){
        int u = vec[i];
        head[u] = -1;
        dfn[u] = low[u] = belong[u] = 0;
    }
    for(int i = 0;i < (int)bridges.size();i++)
        isbridge[bridges[i]] = isbridge[bridges[i] ^ 1] = 0;
    bridges.clear();
}

int main(){
    // freopen("data.in","r",stdin);
    // freopen("data.out","w",stdout);
    memset(head,-1,sizeof(head));
    n = read(); m = read(); Q = read();
    for(int i = 1;i <= m;i++){
        int u = read(),v = read();
        addedge(u,v);
    }
    Init();
    for(int q = 1;q <= Q;q++){
        int ni = read(),mi = read();
        vector<pii> edges;
        vector<int> vec,nodes;
        edges.clear();
        vec.clear();
        nodes.clear();
        for(int i = 1;i <= ni;i++){
            int x = read();
            Rotate(x);
            x = bel[x];
            vec.push_back(x);
            nodes.push_back(x);
        }
        for(int i = 1;i <= mi;i++){
            int x = read(),y = read();
            Rotate(x);
            Rotate(y);
            x = bel[x];
            y = bel[y];
            if(x == y)
                continue;
            edges.push_back(make_pair(x,y));
            nodes.push_back(x);
            nodes.push_back(y);
        }
        sort(nodes.begin(),nodes.end());
        nodes.erase(unique(nodes.begin(),nodes.end()),nodes.end());
        BuildTree(nodes);
        for(int i = 0;i < (int)edges.size();i++)
            addedge(edges[i].first,edges[i].second);
        Getedcc(nodes);
        int id = belong[vec[0]];
        int flag = 1;
        for(int i = 1;i < (int)vec.size();i++){
            if(belong[vec[i]] != id){
                flag = 0;
                break;
            }
        }
        if(flag)
            puts("YES");
        else
            puts("NO");
        if(flag)
            R = (R + q) % n;
        Clear(nodes);
    }
    return 0;
}


#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <bitset>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define PR pair
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define md ((L+R)>>1)
#define For(i,x,y)   for(int i=(int)(x);i<=(int)(y);i++)
#define Rep(i,x,y)   for(int i=(int)(x);i< (int)(y);i++)
#define Forn(i,x,y)  for(int i=(int)(x);i>=(int)(y);i--)
#define CH	         ch=getchar()
#define Exit(...)    printf(__VA_ARGS__),exit(0)
#define dln()        fprintf(stderr,"\n")
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef double	  db;
typedef long long ll;
typedef PR<int,int> PII;
const	int inf=2e9;
const	ll Inf=1e10;
const	int P=1e9+7;
const	int N=1200005;

inline int IN(){
	int x=0;int ch=0,f=0;
	for(CH;ch!=-1&&(ch<48||ch>57);CH)  f=(ch=='-');
	for(;ch>=48&&ch<=57;CH) x=(x<<1)+(x<<3)+ch-'0';
	return f?(-x):x;
}

int Pow(int x,int y,int p){
	int a=1;
	for(;y;y>>=1,x=(ll)x*x%p) if(y&1) a=(ll)a*x%p;
	return a;
}

int n,m,q,bel[N],cnt,Id[N];
set<int> ver;
vector<PII> ori_e;

namespace Bicon{
	vector<PII> ori_e;
	vector<int> e[N];
	int n,m,st[N],ed[N],tim,tfa[19][N],*fa=tfa[0],dep[N];
	int vis[N],A[N],K,stk[N],top;
	void dfs(int x){
		vis[x]=1;
		st[x]=++tim;
		for(int v:e[x]){
			if(v==fa[x])continue;
			dep[v]=dep[x]+1;
			fa[v]=x;
			dfs(v);
		}
		ed[x]=tim;
	}
	int lca(int x,int y){
		if(dep[x]<dep[y]) swap(x,y);
		Forn(i,18,0) if(dep[tfa[i][x]]>=dep[y]) x=tfa[i][x];
		if(x==y) return x;
		Forn(i,18,0) if(tfa[i][x]^tfa[i][y]) x=tfa[i][x],y=tfa[i][y];
		return fa[x];
	}
	void build(int n_){
		n=n_;
		m=ori_e.size();
		tim=0;
		Rep(i,0,m){
			int u=ori_e[i].fi,v=ori_e[i].se;
			e[u].pb(v); e[v].pb(u);
		}
		For(i,1,n) if(!vis[i]){
			dep[i]=1;
			dfs(i);
		} ed[0]=n;
		For(i,1,18) For(j,1,n) tfa[i][j]=tfa[i-1][tfa[i-1][j]];
	}
	int cmp(const int &a,const int &b){
		return st[a]<st[b];
	}
	int vir(){
		K=0; ::ori_e.clear();
		for(auto i:ver) A[++K]=i;
		sort(A+1,A+K+1,cmp);
		int tmp=K;
		Rep(i,1,tmp) A[++K]=lca(A[i],A[i+1]); A[++K]=0;
		sort(A+1,A+K+1,cmp);
		K=unique(A+1,A+K+1)-(A+1);
		top=0;
		For(i,1,K) Id[A[i]]=i-1;
		Rep(i,0,ori_e.size()){
			int ui=ori_e[i].fi,vi=ori_e[i].se;
			ui=Id[ui],vi=Id[vi];
			::ori_e.pb(mk(ui,vi));
		}
		For(i,1,K){
			int u=i;
			while(top&&st[A[u]]>ed[A[stk[top]]]) --top;
			if(top&&A[u]&&A[stk[top]])
				::ori_e.pb(mk(u-1,stk[top]-1));
			stk[++top]=u;
		}
		return K-1;
	}
}

ll last;
void rot(int &u){
	u=(u+last-1)%n+1;
}

int seq[N],tot;
namespace Graph{
	vector<PII> ori_e;
	vector<int> e[N];
	int n,vis[N],fa[N],f[N],T[N],dep[N],m,bel[N],cnt;
	void dfs(int x){
		vis[x]=1;
		for(auto v:e[x])if(!vis[v]){
			fa[v]=x;
			dep[v]=dep[x]+1;
			dfs(v);
		}
	}
	int get(int x){
		if(f[x]==x) return x;
		return f[x]=get(f[x]);
	}
	void build(int n_){
		n=n_; m=ori_e.size();
		For(i,1,n) e[i].clear();
		For(i,1,n){
			vis[i]=fa[i]=T[i]=0;
			dep[i]=1;
			f[i]=i;
		}
		Rep(i,0,m){
			int u=ori_e[i].fi,v=ori_e[i].se;
			e[u].pb(v); e[v].pb(u);
		}
		For(i,1,n) if(!vis[i]) dfs(i);
		Rep(i,0,m){
			int u=ori_e[i].fi,v=ori_e[i].se;
			if(v==fa[u])swap(u,v);
			if(u==fa[v]&&!T[v]){
				T[v]=1;
				continue;
			}
			while(1){
				int du=get(u),dv=get(v);
				if(du==dv) break;
				if(dep[du]<dep[dv]){
					swap(u,v);
					swap(du,dv);
				}
				f[du]=fa[du];
				u=fa[du];
			}
		}

		cnt=0;
		For(i,1,n) if(get(i)==i) bel[i]=++cnt;
//		dprintf("%d\n",cnt);
		For(i,1,n) bel[i]=bel[get(i)];

	}
	int Query(){
		For(i,1,tot) seq[i]=bel[Id[seq[i]]];
		For(i,1,tot) if(seq[i]!=seq[1]) return 0;
		return 1;
	}
	void Into(){
		For(i,1,n) if(get(i)==i&&fa[i]){
			Bicon::ori_e.pb(mk(bel[i],bel[fa[i]]));
		}
	}
}

int main(){
	scanf("%d%d%d",&n,&m,&q);
	For(i,1,m){
		int x,y;
		scanf("%d%d",&x,&y);
		Graph::ori_e.pb(mk(x,y));
	}
	Graph::build(n);
	Graph::Into();
	cnt=Graph::cnt;
	For(i,1,n) bel[i]=Graph::bel[i];
	Bicon::build(cnt);

	For(gtw,1,q){
		Bicon::ori_e.clear();
		int ni=IN(),mi=IN(); ver.clear();
		tot=ni;
		For(i,1,ni){
			int xi=IN(); rot(xi);
			seq[i]=bel[xi];
			ver.insert(bel[xi]);
		}
		For(i,1,mi){
			int ui=IN(),vi=IN(); rot(ui),rot(vi);
			ui=bel[ui],vi=bel[vi];
			ver.insert(ui);
			ver.insert(vi);
			Bicon::ori_e.pb(mk(ui,vi));
		}
		int tmp=Bicon::vir();
		Graph::ori_e=ori_e;
		Graph::build(tmp);
		int Ans=Graph::Query();
		if(Ans) last+=gtw;
		puts(Ans?"YES":"NO");
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
//for tarjan
struct Graph{
	struct Edge{
		int v,nxt;
	}e[1200010];
	int tot;
	int first[300010];
	void build(int u,int v)
	{
		e[++tot]=(Edge){v,first[u]};
		first[u]=tot;
		return ;
	}
	void adde(int u,int v)
	{
		build(u,v);
		build(v,u);
		return ;
	}
	int dfn[300010],low[300010],now;
	int sta[300010],head;
	bool insta[300010];
	int c[300010],color;
	Graph(){
		tot=1;now=color=head=0;
		memset(first,0,sizeof(first));
		memset(dfn,0,sizeof(dfn));
		memset(low,0,sizeof(low));
		memset(c,0,sizeof(c));
		memset(insta,0,sizeof(insta));
		return ;
	}
	void clear()
	{
		tot=1;now=color=head=0;
		return ;
	}
	void clear_node(int u)
	{
		first[u]=0;
		dfn[u]=0;
		low[u]=0;
		c[u]=0;
		return ;
	}
	void dfs(int u,int lste)
	{
		dfn[u]=low[u]=++now;
		sta[++head]=u;
		insta[u]=true;
		for(int i=first[u];i;i=e[i].nxt)
		{
			int v=e[i].v;
			if(i==(lste^1))continue;
			if(!dfn[v]){
				dfs(v,i);
				low[u]=min(low[u],low[v]);
			}
			else if(insta[v])
				low[u]=min(low[u],dfn[v]);
		}
		if(low[u]==dfn[u])
		{
			color++;
			do{
				insta[sta[head]]=false;
				c[sta[head]]=color;
			}while(sta[head--]!=u);
		}
		return ;
	}
}Orig,G;
//init
vector<int>to[300010];
int Rt[300010];
int Dfn[300010],Now;
int Dep[300010];
int F[300010][20];
void Dfs(int u,int rt)
{
	Dfn[u]=++Now;
	Rt[u]=rt;
	for(int i=1;i<20;i++)
		F[u][i]=F[F[u][i-1]][i-1];
	for(int i=0;i<to[u].size();i++)
	{
		int v=to[u][i];
		if(Dfn[v])continue;
		F[v][0]=u;
		Dep[v]=Dep[u]+1;
		Dfs(v,rt);
	}
	return ;
}
int getlca(int x,int y)
{
	if(Dep[x]<Dep[y])swap(x,y);
	int need=Dep[x]-Dep[y],now=0;
	while(need)
	{
		if(need&1)x=F[x][now];
		need>>=1;
		now++;
	}
	if(x==y)return x;
	for(int i=19;i>=0;i--)
		if(F[x][i]!=F[y][i])
			x=F[x][i],y=F[y][i];
	return F[x][0];
}
//t...r...e...e
vector<int>temp;
int Sta[300010],Head;
void extend(int x)
{
	temp.push_back(x);
	if(Rt[Sta[Head]]!=Rt[x])
	{
		while(Head>1)
		{
			G.adde(Sta[Head-1],Sta[Head]);
			Head--;
		}
		Head--;
	}
	if(!Head){
		Sta[++Head]=x;
		return ;
	}
	int Lca=getlca(x,Sta[Head]);
	while(Head>1&&Dep[Sta[Head-1]]>=Dep[Lca])
	{
		G.adde(Sta[Head-1],Sta[Head]);
		Head--;
	}
	if(Sta[Head]!=Lca)
	{
		temp.push_back(Lca);
		G.adde(Lca,Sta[Head]);
		Sta[Head]=Lca;
	}
	Sta[++Head]=x;
	return ;
}

int x[300010];
bool cmp(int numx,int numy)
{
	return Dfn[numx]<Dfn[numy];
}
int A[900010];

//for input
int n;

int R;
int rotate(int element)
{
   element=(element+R)%n;

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

   return element;
}
void getele(int& element)
{
	scanf("%d",&element);
	element=rotate(element);
	return ;
}

//solve
void solve()
{
	//solve
	int nn,mm;
	scanf("%d %d",&nn,&mm);
	int nnum=0;
	for(int i=1;i<=nn;i++)
	{
		getele(x[i]);
		x[i]=Orig.c[x[i]];
		A[++nnum]=i;
	}
	for(int i=1;i<=mm;i++)
	{
		int u,v;
		getele(u);
		getele(v);
		u=Orig.c[u];
		v=Orig.c[v];
		G.adde(u,v);
		A[++nnum]=u;
		A[++nnum]=v;
	}
	sort(A+1,A+nnum+1);
	nnum=unique(A+1,A+nnum+1)-A-1;
	sort(A+1,A+nnum+1,cmp);
	for(int i=1;i<=nnum;i++)
		extend(A[i]);
	while(Head>1){
		G.adde(Sta[Head-1],Sta[Head]);
		Head--;
	}
	G.dfs(x[1],0);
	bool flag=true;
	for(int i=2;i<=nn;i++)
		if(G.c[x[i]]!=G.c[x[1]])
			flag=false;
	if(flag)printf("YES\n");
	else printf("NO\n");
	R+=flag;

	//clear
	for(int i=0;i<temp.size();i++)
		G.clear_node(temp[i]);
	G.clear();
	Head=0;
	temp.clear();

	return ;
}
int main()
{
	int m,q;
	scanf("%d %d %d",&n,&m,&q);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		Orig.adde(u,v);
	}
	for(int i=1;i<=n;i++)
		if(!Orig.dfn[i])
			Orig.dfs(i,0);
	int N=Orig.color;
	for(int i=1;i<=n;i++)
		for(int j=Orig.first[i];j;j=Orig.e[j].nxt)
		{
			int u=i;
			int v=Orig.e[j].v;
			to[Orig.c[u]].push_back(Orig.c[v]);
		}
	for(int i=1;i<=N;i++)
		if(!Dfn[i])
			Dfs(i,i);
	while(q--)
		solve();
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
//for tarjan
struct Graph{
	struct Edge{
		int v,nxt;
	}e[1200010];
	int tot;
	int first[300010];
	void build(int u,int v)
	{
		e[++tot]=(Edge){v,first[u]};
		first[u]=tot;
		return ;
	}
	void adde(int u,int v)
	{
		build(u,v);
		build(v,u);
		return ;
	}
	int dfn[300010],low[300010],now;
	int sta[300010],head;
	bool insta[300010];
	int c[300010],color;
	Graph(){
		tot=1;now=color=head=0;
		memset(first,0,sizeof(first));
		memset(dfn,0,sizeof(dfn));
		memset(low,0,sizeof(low));
		memset(c,0,sizeof(c));
		memset(insta,0,sizeof(insta));
		return ;
	}
	void clear()
	{
		tot=1;now=color=head=0;
		return ;
	}
	void clear_node(int u)
	{
		first[u]=0;
		dfn[u]=0;
		low[u]=0;
		c[u]=0;
		return ;
	}
	void dfs(int u,int lste)
	{
		dfn[u]=low[u]=++now;
		sta[++head]=u;
		insta[u]=true;
		for(int i=first[u];i;i=e[i].nxt)
		{
			int v=e[i].v;
			if(i==(lste^1))continue;
			if(!dfn[v]){
				dfs(v,i);
				low[u]=min(low[u],low[v]);
			}
			else if(insta[v])
				low[u]=min(low[u],dfn[v]);
		}
		if(low[u]==dfn[u])
		{
			color++;
			do{
				insta[sta[head]]=false;
				c[sta[head]]=color;
			}while(sta[head--]!=u);
		}
		return ;
	}
}Orig,G;
//init
vector<int>to[300010];
int Rt[300010];
int Dfn[300010],Now;
int Dep[300010];
int F[300010][20];
void Dfs(int u,int rt)
{
	Dfn[u]=++Now;
	Rt[u]=rt;
	for(int i=1;i<20;i++)
		F[u][i]=F[F[u][i-1]][i-1];
	for(int i=0;i<to[u].size();i++)
	{
		int v=to[u][i];
		if(Dfn[v])continue;
		F[v][0]=u;
		Dep[v]=Dep[u]+1;
		Dfs(v,rt);
	}
	return ;
}
int getlca(int x,int y)
{
	if(Dep[x]<Dep[y])swap(x,y);
	int need=Dep[x]-Dep[y],now=0;
	while(need)
	{
		if(need&1)x=F[x][now];
		need>>=1;
		now++;
	}
	if(x==y)return x;
	for(int i=19;i>=0;i--)
		if(F[x][i]!=F[y][i])
			x=F[x][i],y=F[y][i];
	return F[x][0];
}
//t...r...e...e
vector<int>temp;
int Sta[300010],Head;
void extend(int x)
{
	temp.push_back(x);
	if(Head>0&&Rt[Sta[Head]]!=Rt[x])
	{
		while(Head>1)
		{
			G.adde(Sta[Head-1],Sta[Head]);
			Head--;
		}
		Head--;
	}
	if(!Head){
		Sta[++Head]=x;
		return ;
	}
	int Lca=getlca(x,Sta[Head]);
	while(Head>1&&Dep[Sta[Head-1]]>=Dep[Lca])
	{
		G.adde(Sta[Head-1],Sta[Head]);
		Head--;
	}
	if(Sta[Head]!=Lca)
	{
		temp.push_back(Lca);
		G.adde(Lca,Sta[Head]);
		Sta[Head]=Lca;
	}
	Sta[++Head]=x;
	return ;
}

int x[300010];
bool cmp(int numx,int numy)
{
	return Dfn[numx]<Dfn[numy];
}
int A[900010];

//for input
int n;

long long R;
int rotate(int element)
{
   element=(element+R)%n;

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

   return element;
}
void getele(int& element)
{
	scanf("%d",&element);
	element=rotate(element);
	return ;
}

//solve
void solve(int query_id)
{
	//solve
	int nn,mm;
	scanf("%d %d",&nn,&mm);
	int nnum=0;
	for(int i=1;i<=nn;i++)
	{
		getele(x[i]);
		x[i]=Orig.c[x[i]];
		A[++nnum]=x[i];
	}
	for(int i=1;i<=mm;i++)
	{
		int u,v;
		getele(u);
		getele(v);
		u=Orig.c[u];
		v=Orig.c[v];
		G.adde(u,v);
		A[++nnum]=u;
		A[++nnum]=v;
	}
	sort(A+1,A+nnum+1);
	nnum=unique(A+1,A+nnum+1)-A-1;
	sort(A+1,A+nnum+1,cmp);
	for(int i=1;i<=nnum;i++)
		extend(A[i]);
	while(Head>1){
		G.adde(Sta[Head-1],Sta[Head]);
		Head--;
	}
	G.dfs(x[1],0);
	bool flag=true;
	for(int i=2;i<=nn;i++)
		if(G.c[x[i]]!=G.c[x[1]])
			flag=false;
	if(flag)printf("YES\n");
	else printf("NO\n");
	R+=flag*query_id;

	//clear
	for(int i=0;i<temp.size();i++)
		G.clear_node(temp[i]);
	G.clear();
	Head=0;
	temp.clear();

	return ;
}
int main()
{
	int m,q;
	scanf("%d %d %d",&n,&m,&q);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		Orig.adde(u,v);
	}
	for(int i=1;i<=n;i++)
		if(!Orig.dfn[i])
			Orig.dfs(i,0);
	int N=Orig.color;
	for(int i=1;i<=n;i++)
		for(int j=Orig.first[i];j;j=Orig.e[j].nxt)
		{
			int u=i;
			int v=Orig.e[j].v;
			to[Orig.c[u]].push_back(Orig.c[v]);
		}
	for(int i=1;i<=N;i++)
		if(!Dfn[i])
			Dfs(i,i);
	for(int i=1;i<=q;i++)
		solve(i);
	return 0;
}


#include <bits/stdc++.h>

using std::cerr;
using std::endl;

const int S = 300000 * 100;

char buc_in[S], *p_in = buc_in;

inline int rd() {
  int b = 0;
  while (!isdigit(*p_in)) ++p_in;
  while (isdigit(*p_in)) b = b * 10 + *p_in++ - '0';
  return b;
}

const int N = 3e5 + 233;

int n, m, q;
int tarjan_tag = 1;

struct Graph {
  int to, nxt;
} G[N * 4];
int head[N], etot = 1;

int graph_stk[N * 4], graph_top;

inline void addedge(int x, int y) {
  /*
  if (!tarjan_tag)
    cerr << x << " " << y << endl;
  */
  G[++etot] = { y, head[x] }, head[x] = etot;
  graph_stk[++graph_top] = x;
}

inline void clear_graph() {
  while (graph_top)
    head[graph_stk[graph_top--]] = 0;
  etot = 1;
}

int dfn[N], low[N], num, stk[N], top, bel[N], Bel[N], cnt;

void tarjan(int x, int fa) {
  dfn[x] = low[x] = ++num;
  stk[++top] = x;
  for (int i = head[x]; i; i = G[i].nxt) {
    if ((i ^ 1) == fa) continue;
    int y = G[i].to;
    if (!dfn[y]) {
      tarjan(y, i);
      low[x] = std::min(low[x], low[y]);
    } else
      low[x] = std::min(low[x], dfn[y]);
  }
  if (low[x] == dfn[x]) {
    ++cnt;
    for (int y = 0; y != x; --top) {
      y = stk[top];
      if (tarjan_tag)
        bel[y] = cnt;
      else
        Bel[y] = cnt;
    }
  }
}

std::set<std::pair<int, int>> set;

inline int check_edge(int x, int y) {
  if (x > y) std::swap(x, y);
  if (set.find({ x, y }) != set.end())
    return 0;
  set.insert({ x, y });
  return 1;
}

std::vector<int> T[N];

int ans;

inline int online(int x) {
  x = (x + ans) % n;
  if (x == 0) x = n;
  return x;
}

int dad[N][21], dep[N], root[N];
int id[N], dd;

void dfs(int x, int fa) {
  dad[x][0] = fa;
  id[x] = ++dd;
  if (!fa) root[x] = x;
  else root[x] = root[fa];
  dep[x] = dep[fa] + 1;
  for (int i = 1; i <= 20; ++i)
    dad[x][i] = dad[dad[x][i - 1]][i - 1];
  for (int y : T[x])
    if (y != fa)
      dfs(y, x);
}

inline int get_lca(int x, int y) {
  if (dep[x] < dep[y])
    std::swap(x, y);
  for (int i = 20; ~i; --i)
    if (dep[dad[x][i]] >= dep[y])
      x = dad[x][i];
  if (x == y) return x;
  for (int i = 20; ~i; --i)
    if (dad[x][i] != dad[y][i])
      x = dad[x][i], y = dad[y][i];
  return dad[x][0];
}

inline void insert(int x, int stk[], int &top) {
  if (top <= 1)
    stk[++top] = x;
  else {
    int lca = get_lca(x, stk[top]);
    if (lca != stk[top]) {
      while (top > 1 && id[stk[top - 1]] >= id[lca]) {
        addedge(stk[top - 1], stk[top]);
        addedge(stk[top], stk[top - 1]);
        --top;
      }
      if (lca != stk[top]) {
        addedge(lca, stk[top]);
        addedge(stk[top], lca);
        stk[top] = lca;
      }
    }
    stk[++top] = x;
  }
}

inline void build(std::vector<int> &pt, int l, int r) {
  static int stk[N], top;
  top = 0;
  for (int i = l; i <= r; ++i) {
    insert(pt[i], stk, top);
  }
  while (top > 1) {
    addedge(stk[top - 1], stk[top]);
    addedge(stk[top], stk[top - 1]);
    --top;
  }
}

inline void build_vtree(std::vector<int> &pt) {
  int up = pt.size();
  for (int i = 0; i < up; ++i)
    pt.push_back(root[pt[i]]);
  std::sort(pt.begin(), pt.end());
  pt.resize(std::unique(pt.begin(), pt.end()) - pt.begin());
  std::sort(pt.begin(), pt.end(), [&](int x, int y)
    { return id[x] < id[y]; });

  /*
  for (int x : pt)
    cerr << x << " ";
  cerr << endl;
  */

  for (int i = 0, j = 0; i < (int)pt.size(); ++i) {
    if (i + 1 < (int)pt.size() && root[pt[i]] != root[pt[i + 1]]) {
      build(pt, j, i);
      j = i + 1;
      continue;
    }
    if (i == (int)pt.size() - 1) {
      build(pt, j, i);
      continue;
    }
  }

  /*
  for (auto x : pt)
    insert(x, stk, top);
  while (top > 1) {
    addedge(stk[top - 1], stk[top]);
    addedge(stk[top], stk[top - 1]);
    --top;
  }
  */
}

inline int check_ans(std::vector<int> &pt) {
  for (int x : pt) {
    if (!dfn[x])
      tarjan(x, 0);
    // cerr << x << endl;
  }
  /*
  if (cnt != 1)
    return 0;
  */
  int now = 0;
  for (int x : pt) {
    if (!now)
      now = Bel[x];
    else {
      if (now != Bel[x])
        return 0;
    }
  }
  return 1;
}

inline void clear(std::vector<int> &pt) {
  /*
  clear_graph();
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  num = 0;
  top = 0;
  cnt = 0;
  */
  while (graph_top) {
    int x = graph_stk[graph_top];
    --graph_top;
    head[x] = 0;
    dfn[x] = 0;
    low[x] = 0;
  }
  for (int x : pt) {
    head[x] = dfn[x] = low[x] = 0;
  }
  num = top = cnt = 0;
  etot = 1;
}

int main() {
//   freopen("data", "r", stdin);
  fread(buc_in, 1, S, stdin);
  n = rd(), m = rd(), q = rd();
  for (int i = 1; i <= m; ++i) {
    int x = rd(), y = rd();
    addedge(x, y);
    addedge(y, x);
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i, 0);

  tarjan_tag = 0;

  for (int x = 1; x <= n; ++x) {
    for (int i = head[x]; i; i = G[i].nxt) {
      int y = G[i].to;
      if (bel[x] != bel[y]) {
        if (check_edge(bel[x], bel[y])) {
          T[bel[x]].push_back(bel[y]);
          T[bel[y]].push_back(bel[x]);
        }
      }
    }
  }

  for (int i = 1; i <= cnt; ++i)
    if (!root[i])
      dfs(i, 0);

  /*
  for (int i = 1; i <= n; ++i)
    cerr << bel[i] << " ";
  cerr << endl;
  */

  clear_graph();
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  num = 0;
  top = 0;
  cnt = 0;

  for (int ver = 1; ver <= q; ++ver) {
    int n = rd(), m = rd();

    std::vector<int> pt, raw_pt;
    for (int i = 1; i <= n; ++i) {
      int x = rd();
      x = online(x);
      // cerr << x << endl;
      pt.push_back(bel[x]);
      raw_pt.push_back(bel[x]);
    }
    for (int i = 1; i <= m; ++i) {
      int x = rd(), y = rd();
      x = online(x);
      y = online(y);
      // cerr << x << " " << y << endl;
      x = bel[x];
      y = bel[y];
      if (x == y)
        continue;
      addedge(x, y);
      addedge(y, x);
      pt.push_back(x);
      pt.push_back(y);
    }
    build_vtree(pt);
    int now = check_ans(raw_pt);
    if (now) {
      puts("YES");
      ans += ver;
      ans %= ::n;
    } else {
      puts("NO");
    }
    clear(pt);
  }
  return 0;
}


#include <bits/stdc++.h>

using std::cerr;
using std::endl;

const int S = 100000 * 20;

char buc_in[S], *p_in = buc_in;

inline int rd() {
  int b = 0;
  while (!isdigit(*p_in)) ++p_in;
  while (isdigit(*p_in)) b = b * 10 + *p_in++ - '0';
  return b;
}

const int N = 3e5 + 233;

int n, m, q;
int tarjan_tag = 1;

struct Graph {
  int to, nxt;
} G[N * 2];
int head[N], etot = 1;

int graph_stk[N], graph_top;

inline void addedge(int x, int y) {
  G[++etot] = { y, head[x] }, head[x] = etot;
  graph_stk[++graph_top] = x;
}

inline void clear_graph() {
  while (graph_top)
    head[graph_stk[graph_top--]] = 0;
  etot = 1;
}

int dfn[N], low[N], num, stk[N], top, bel[N], cnt;

void tarjan(int x, int fa) {
  dfn[x] = low[x] = ++num;
  stk[++top] = x;
  for (int i = head[x]; i; i = G[i].nxt) {
    if ((i ^ 1) == fa) continue;
    int y = G[i].to;
    if (!dfn[y]) {
      tarjan(y, i);
      low[x] = std::min(low[x], low[y]);
    } else
      low[x] = std::min(low[x], dfn[y]);
  }
  if (low[x] == dfn[x]) {
    ++cnt;
    for (int y = 0; y != x; --top) {
      y = stk[top];
      if (tarjan_tag)
        bel[y] = cnt;
    }
  }
}

std::set<std::pair<int, int>> set;

inline int check_edge(int x, int y) {
  if (x > y) std::swap(x, y);
  if (set.find({ x, y }) != set.end())
    return 0;
  set.insert({ x, y });
  return 1;
}

std::vector<int> T[N];

int ans;

inline int online(int x) {
  x = (x + ans) % n;
  if (x == 0) x = n;
  return x;
}

int dad[N][21], dep[N], root[N];
int id[N], dd;

void dfs(int x, int fa) {
  dad[x][0] = fa;
  id[x] = ++dd;
  if (!fa) root[x] = x;
  else root[x] = root[fa];
  dep[x] = dep[fa] + 1;
  for (int i = 1; i <= 20; ++i)
    dad[x][i] = dad[dad[x][i - 1]][i - 1];
  for (int y : T[x])
    if (y != fa)
      dfs(y, x);
}

inline int get_lca(int x, int y) {
  if (dep[x] < dep[y])
    std::swap(x, y);
  for (int i = 20; ~i; --i)
    if (dep[dad[x][i]] >= dep[y])
      x = dad[x][i];
  if (x == y) return x;
  for (int i = 20; ~i; --i)
    if (dad[x][i] != dad[y][i])
      x = dad[x][i], y = dad[y][i];
  return dad[x][0];
}

inline void insert(int x, int stk[], int &top) {
  if (top <= 1)
    stk[++top] = x;
  else {
    int lca = get_lca(x, stk[top]);
    if (lca != stk[top]) {
      while (top > 1 && id[stk[top - 1]] >= id[lca]) {
        addedge(stk[top - 1], stk[top]);
        addedge(stk[top], stk[top - 1]);
        --top;
      }
      if (lca != stk[top]) {
        addedge(lca, stk[top]);
        addedge(stk[top], lca);
        stk[top] = lca;
      }
    }
    stk[++top] = x;
  }
}

inline void build_vtree(std::vector<int> &pt) {
  int up = pt.size();
  for (int i = 0; i < up; ++i)
    pt.push_back(root[pt[i]]);
  std::sort(pt.begin(), pt.end());
  pt.resize(std::unique(pt.begin(), pt.end()) - pt.begin());
  std::sort(pt.begin(), pt.end(), [&](int x, int y)
    { return id[x] < id[y]; });

  /*
  for (int i : pt)
    cerr << i << " ";
  cerr << endl;
  */

  static int stk[N], top;
  top = 0;
  for (auto x : pt)
    insert(x, stk, top);
  while (top > 1) {
    addedge(stk[top - 1], stk[top]);
    addedge(stk[top], stk[top - 1]);
    --top;
  }
}

inline int check_ans(std::vector<int> &pt) {
  for (int x : pt)
    if (!dfn[x])
      tarjan(x, 0);
  if (cnt != 1)
    return 0;
  return 1;
}

inline void clear(std::vector<int> &pt) {
  /*
  clear_graph();
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  num = 0;
  top = 0;
  cnt = 0;
  */
  while (graph_top) {
    int x = graph_stk[graph_top];
    --graph_top;
    head[x] = 0;
    dfn[x] = 0;
    low[x] = 0;
  }
  for (int x : pt) {
    head[x] = dfn[x] = low[x] = 0;
  }
  num = top = cnt = 0;
  etot = 1;
}

int main() {
//   freopen("data", "r", stdin);
  fread(buc_in, 1, S, stdin);
  n = rd(), m = rd(), q = rd();
  for (int i = 1; i <= m; ++i) {
    int x = rd(), y = rd();
    addedge(x, y);
    addedge(y, x);
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i, 0);

  tarjan_tag = 0;

  for (int x = 1; x <= n; ++x) {
    for (int i = head[x]; i; i = G[i].nxt) {
      int y = G[i].to;
      if (bel[x] != bel[y]) {
        if (check_edge(bel[x], bel[y])) {
          T[bel[x]].push_back(bel[y]);
          T[bel[y]].push_back(bel[x]);
        }
      }
    }
  }

  for (int i = 1; i <= cnt; ++i)
    if (!root[i])
      dfs(i, 0);

  clear_graph();
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  num = 0;
  top = 0;
  cnt = 0;

  for (int ver = 1; ver <= q; ++ver) {
    int n = rd(), m = rd();

    std::vector<int> pt, raw_pt;
    for (int i = 1; i <= n; ++i) {
      int x = rd();
      x = online(x);
      pt.push_back(bel[x]);
      raw_pt.push_back(bel[x]);
    }
    for (int i = 1; i <= m; ++i) {
      int x = rd(), y = rd();
      x = online(x);
      y = online(y);
      x = bel[x];
      y = bel[y];
      if (x == y)
        continue;
      addedge(x, y);
      addedge(y, x);
      pt.push_back(x);
      pt.push_back(y);
    }
    build_vtree(pt);
    int now = check_ans(raw_pt);
    if (now) {
      puts("YES");
      ans += ver;
      ans %= n;
    } else {
      puts("NO");
    }
    clear(pt);
  }
  return 0;
}


#include <bits/stdc++.h>

using std::cerr;
using std::endl;

const int S = 100000 * 20;

char buc_in[S], *p_in = buc_in;

inline int rd() {
  int b = 0;
  while (!isdigit(*p_in)) ++p_in;
  while (isdigit(*p_in)) b = b * 10 + *p_in++ - '0';
  return b;
}

const int N = 3e5 + 233;

int n, m, q;
int tarjan_tag = 1;

struct Graph {
  int to, nxt;
} G[N * 4];
int head[N], etot = 1;

int graph_stk[N * 4], graph_top;

inline void addedge(int x, int y) {
  /*
  if (!tarjan_tag)
    cerr << x << " " << y << endl;
  */
  G[++etot] = { y, head[x] }, head[x] = etot;
  graph_stk[++graph_top] = x;
}

inline void clear_graph() {
  while (graph_top)
    head[graph_stk[graph_top--]] = 0;
  etot = 1;
}

int dfn[N], low[N], num, stk[N], top, bel[N], Bel[N], cnt;

void tarjan(int x, int fa) {
  dfn[x] = low[x] = ++num;
  stk[++top] = x;
  for (int i = head[x]; i; i = G[i].nxt) {
    if ((i ^ 1) == fa) continue;
    int y = G[i].to;
    if (!dfn[y]) {
      tarjan(y, i);
      low[x] = std::min(low[x], low[y]);
    } else
      low[x] = std::min(low[x], dfn[y]);
  }
  if (low[x] == dfn[x]) {
    ++cnt;
    for (int y = 0; y != x; --top) {
      y = stk[top];
      if (tarjan_tag)
        bel[y] = cnt;
      else
        Bel[y] = cnt;
    }
  }
}

std::set<std::pair<int, int>> set;

inline int check_edge(int x, int y) {
  if (x > y) std::swap(x, y);
  if (set.find({ x, y }) != set.end())
    return 0;
  set.insert({ x, y });
  return 1;
}

std::vector<int> T[N];

int ans;

inline int online(int x) {
  x = (x + ans) % n;
  if (x == 0) x = n;
  return x;
}

int dad[N][21], dep[N], root[N];
int id[N], dd;

void dfs(int x, int fa) {
  dad[x][0] = fa;
  id[x] = ++dd;
  if (!fa) root[x] = x;
  else root[x] = root[fa];
  dep[x] = dep[fa] + 1;
  for (int i = 1; i <= 20; ++i)
    dad[x][i] = dad[dad[x][i - 1]][i - 1];
  for (int y : T[x])
    if (y != fa)
      dfs(y, x);
}

inline int get_lca(int x, int y) {
  if (dep[x] < dep[y])
    std::swap(x, y);
  for (int i = 20; ~i; --i)
    if (dep[dad[x][i]] >= dep[y])
      x = dad[x][i];
  if (x == y) return x;
  for (int i = 20; ~i; --i)
    if (dad[x][i] != dad[y][i])
      x = dad[x][i], y = dad[y][i];
  return dad[x][0];
}

inline void insert(int x, int stk[], int &top) {
  if (top <= 1)
    stk[++top] = x;
  else {
    int lca = get_lca(x, stk[top]);
    if (lca != stk[top]) {
      while (top > 1 && id[stk[top - 1]] >= id[lca]) {
        addedge(stk[top - 1], stk[top]);
        addedge(stk[top], stk[top - 1]);
        --top;
      }
      if (lca != stk[top]) {
        addedge(lca, stk[top]);
        addedge(stk[top], lca);
        stk[top] = lca;
      }
    }
    stk[++top] = x;
  }
}

inline void build(std::vector<int> &pt, int l, int r) {
  static int stk[N], top;
  top = 0;
  for (int i = l; i <= r; ++i) {
    insert(pt[i], stk, top);
  }
  while (top > 1) {
    addedge(stk[top - 1], stk[top]);
    addedge(stk[top], stk[top - 1]);
    --top;
  }
}

inline void build_vtree(std::vector<int> &pt) {
  int up = pt.size();
  for (int i = 0; i < up; ++i)
    pt.push_back(root[pt[i]]);
  std::sort(pt.begin(), pt.end());
  pt.resize(std::unique(pt.begin(), pt.end()) - pt.begin());
  std::sort(pt.begin(), pt.end(), [&](int x, int y)
    { return id[x] < id[y]; });

  /*
  for (int x : pt)
    cerr << x << " ";
  cerr << endl;
  */

  for (int i = 0, j = 0; i < (int)pt.size(); ++i) {
    if (i + 1 < (int)pt.size() && root[pt[i]] != root[pt[i + 1]]) {
      build(pt, j, i);
      j = i + 1;
      continue;
    }
    if (i == (int)pt.size() - 1) {
      build(pt, j, i);
      continue;
    }
  }

  /*
  for (auto x : pt)
    insert(x, stk, top);
  while (top > 1) {
    addedge(stk[top - 1], stk[top]);
    addedge(stk[top], stk[top - 1]);
    --top;
  }
  */
}

inline int check_ans(std::vector<int> &pt) {
  for (int x : pt) {
    if (!dfn[x])
      tarjan(x, 0);
    // cerr << x << endl;
  }
  /*
  if (cnt != 1)
    return 0;
  */
  int now = 0;
  for (int x : pt) {
    if (!now)
      now = Bel[x];
    else {
      if (now != Bel[x])
        return 0;
    }
  }
  return 1;
}

inline void clear(std::vector<int> &pt) {
  /*
  clear_graph();
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  num = 0;
  top = 0;
  cnt = 0;
  */
  while (graph_top) {
    int x = graph_stk[graph_top];
    --graph_top;
    head[x] = 0;
    dfn[x] = 0;
    low[x] = 0;
  }
  for (int x : pt) {
    head[x] = dfn[x] = low[x] = 0;
  }
  num = top = cnt = 0;
  etot = 1;
}

int main() {
//   freopen("data", "r", stdin);
  fread(buc_in, 1, S, stdin);
  n = rd(), m = rd(), q = rd();
  for (int i = 1; i <= m; ++i) {
    int x = rd(), y = rd();
    addedge(x, y);
    addedge(y, x);
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i, 0);

  tarjan_tag = 0;

  for (int x = 1; x <= n; ++x) {
    for (int i = head[x]; i; i = G[i].nxt) {
      int y = G[i].to;
      if (bel[x] != bel[y]) {
        if (check_edge(bel[x], bel[y])) {
          T[bel[x]].push_back(bel[y]);
          T[bel[y]].push_back(bel[x]);
        }
      }
    }
  }

  for (int i = 1; i <= cnt; ++i)
    if (!root[i])
      dfs(i, 0);

  /*
  for (int i = 1; i <= n; ++i)
    cerr << bel[i] << " ";
  cerr << endl;
  */

  clear_graph();
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  num = 0;
  top = 0;
  cnt = 0;

  for (int ver = 1; ver <= q; ++ver) {
    int n = rd(), m = rd();

    std::vector<int> pt, raw_pt;
    for (int i = 1; i <= n; ++i) {
      int x = rd();
      x = online(x);
      // cerr << x << endl;
      pt.push_back(bel[x]);
      raw_pt.push_back(bel[x]);
    }
    for (int i = 1; i <= m; ++i) {
      int x = rd(), y = rd();
      x = online(x);
      y = online(y);
      // cerr << x << " " << y << endl;
      x = bel[x];
      y = bel[y];
      if (x == y)
        continue;
      addedge(x, y);
      addedge(y, x);
      pt.push_back(x);
      pt.push_back(y);
    }
    build_vtree(pt);
    int now = check_ans(raw_pt);
    if (now) {
      puts("YES");
      ans += ver;
      ans %= ::n;
    } else {
      puts("NO");
    }
    clear(pt);
  }
  return 0;
}


#include <bits/stdc++.h>

using std::cerr;
using std::endl;

const int S = 100000 * 20;

char buc_in[S], *p_in = buc_in;

inline int rd() {
  int b = 0;
  while (!isdigit(*p_in)) ++p_in;
  while (isdigit(*p_in)) b = b * 10 + *p_in++ - '0';
  return b;
}

const int N = 3e5 + 233;

int n, m, q;
int tarjan_tag = 1;

struct Graph {
  int to, nxt;
} G[N * 2];
int head[N], etot = 1;

int graph_stk[N], graph_top;

inline void addedge(int x, int y) {
  G[++etot] = { y, head[x] }, head[x] = etot;
  graph_stk[++graph_top] = x;
}

inline void clear_graph() {
  while (graph_top)
    head[graph_stk[graph_top--]] = 0;
  etot = 1;
}

int dfn[N], low[N], num, stk[N], top, bel[N], Bel[N], cnt;

void tarjan(int x, int fa) {
  dfn[x] = low[x] = ++num;
  stk[++top] = x;
  for (int i = head[x]; i; i = G[i].nxt) {
    if ((i ^ 1) == fa) continue;
    int y = G[i].to;
    if (!dfn[y]) {
      tarjan(y, i);
      low[x] = std::min(low[x], low[y]);
    } else
      low[x] = std::min(low[x], dfn[y]);
  }
  if (low[x] == dfn[x]) {
    ++cnt;
    for (int y = 0; y != x; --top) {
      y = stk[top];
      if (tarjan_tag)
        bel[y] = cnt;
      else
        Bel[y] = cnt;
    }
  }
}

std::set<std::pair<int, int>> set;

inline int check_edge(int x, int y) {
  if (x > y) std::swap(x, y);
  if (set.find({ x, y }) != set.end())
    return 0;
  set.insert({ x, y });
  return 1;
}

std::vector<int> T[N];

int ans;

inline int online(int x) {
  x = (x + ans) % n;
  if (x == 0) x = n;
  return x;
}

int dad[N][21], dep[N], root[N];
int id[N], dd;

void dfs(int x, int fa) {
  dad[x][0] = fa;
  id[x] = ++dd;
  if (!fa) root[x] = x;
  else root[x] = root[fa];
  dep[x] = dep[fa] + 1;
  for (int i = 1; i <= 20; ++i)
    dad[x][i] = dad[dad[x][i - 1]][i - 1];
  for (int y : T[x])
    if (y != fa)
      dfs(y, x);
}

inline int get_lca(int x, int y) {
  if (dep[x] < dep[y])
    std::swap(x, y);
  for (int i = 20; ~i; --i)
    if (dep[dad[x][i]] >= dep[y])
      x = dad[x][i];
  if (x == y) return x;
  for (int i = 20; ~i; --i)
    if (dad[x][i] != dad[y][i])
      x = dad[x][i], y = dad[y][i];
  return dad[x][0];
}

inline void insert(int x, int stk[], int &top) {
  if (top <= 1)
    stk[++top] = x;
  else {
    int lca = get_lca(x, stk[top]);
    if (lca != stk[top]) {
      while (top > 1 && id[stk[top - 1]] >= id[lca]) {
        addedge(stk[top - 1], stk[top]);
        addedge(stk[top], stk[top - 1]);
        --top;
      }
      if (lca != stk[top]) {
        addedge(lca, stk[top]);
        addedge(stk[top], lca);
        stk[top] = lca;
      }
    }
    stk[++top] = x;
  }
}

inline void build_vtree(std::vector<int> &pt) {
  int up = pt.size();
  for (int i = 0; i < up; ++i)
    pt.push_back(root[pt[i]]);
  std::sort(pt.begin(), pt.end());
  pt.resize(std::unique(pt.begin(), pt.end()) - pt.begin());
  std::sort(pt.begin(), pt.end(), [&](int x, int y)
    { return id[x] < id[y]; });

  /*
  for (int i : pt)
    cerr << i << " ";
  cerr << endl;
  */

  static int stk[N], top;
  top = 0;
  for (auto x : pt)
    insert(x, stk, top);
  while (top > 1) {
    addedge(stk[top - 1], stk[top]);
    addedge(stk[top], stk[top - 1]);
    --top;
  }
}

inline int check_ans(std::vector<int> &pt) {
  for (int x : pt) {
    if (!dfn[x])
      tarjan(x, 0);
    // cerr << x << endl;
  }
  /*
  if (cnt != 1)
    return 0;
  */
  int now = 0;
  for (int x : pt) {
    if (!now)
      x = Bel[x];
    else {
      if (now != Bel[x])
        return 0;
    }
  }
  return 1;
}

inline void clear(std::vector<int> &pt) {
  /*
  clear_graph();
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  num = 0;
  top = 0;
  cnt = 0;
  */
  while (graph_top) {
    int x = graph_stk[graph_top];
    --graph_top;
    head[x] = 0;
    dfn[x] = 0;
    low[x] = 0;
  }
  for (int x : pt) {
    head[x] = dfn[x] = low[x] = 0;
  }
  num = top = cnt = 0;
  etot = 1;
}

int main() {
//   freopen("data", "r", stdin);
  fread(buc_in, 1, S, stdin);
  n = rd(), m = rd(), q = rd();
  for (int i = 1; i <= m; ++i) {
    int x = rd(), y = rd();
    addedge(x, y);
    addedge(y, x);
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i, 0);

  tarjan_tag = 0;

  for (int x = 1; x <= n; ++x) {
    for (int i = head[x]; i; i = G[i].nxt) {
      int y = G[i].to;
      if (bel[x] != bel[y]) {
        if (check_edge(bel[x], bel[y])) {
          T[bel[x]].push_back(bel[y]);
          T[bel[y]].push_back(bel[x]);
        }
      }
    }
  }

  for (int i = 1; i <= cnt; ++i)
    if (!root[i])
      dfs(i, 0);

  /*
  for (int i = 1; i <= n; ++i)
    cerr << bel[i] << " ";
  cerr << endl;
  */

  clear_graph();
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  num = 0;
  top = 0;
  cnt = 0;

  for (int ver = 1; ver <= q; ++ver) {
    int n = rd(), m = rd();

    std::vector<int> pt, raw_pt;
    for (int i = 1; i <= n; ++i) {
      int x = rd();
      x = online(x);
      pt.push_back(bel[x]);
      raw_pt.push_back(bel[x]);
    }
    for (int i = 1; i <= m; ++i) {
      int x = rd(), y = rd();
      x = online(x);
      y = online(y);
      x = bel[x];
      y = bel[y];
      if (x == y)
        continue;
      addedge(x, y);
      addedge(y, x);
      pt.push_back(x);
      pt.push_back(y);
    }
    build_vtree(pt);
    int now = check_ans(raw_pt);
    if (now) {
      puts("YES");
      ans += ver;
      ans %= n;
    } else {
      puts("NO");
    }
    clear(pt);
  }
  return 0;
}


#include <bits/stdc++.h>

using std::cerr;
using std::endl;

const int S = 100000 * 20;

char buc_in[S], *p_in = buc_in;

inline int rd() {
  int b = 0;
  while (!isdigit(*p_in)) ++p_in;
  while (isdigit(*p_in)) b = b * 10 + *p_in++ - '0';
  return b;
}

const int N = 3e5 + 233;

int n, m, q;
int tarjan_tag = 1;

struct Graph {
  int to, nxt;
} G[N * 2];
int head[N], etot = 1;

int graph_stk[N], graph_top;

inline void addedge(int x, int y) {
  G[++etot] = { y, head[x] }, head[x] = etot;
  graph_stk[++graph_top] = x;
}

inline void clear_graph() {
  while (graph_top)
    head[graph_stk[graph_top--]] = 0;
  etot = 1;
}

int dfn[N], low[N], num, stk[N], top, bel[N], Bel[N], cnt;

void tarjan(int x, int fa) {
  dfn[x] = low[x] = ++num;
  stk[++top] = x;
  for (int i = head[x]; i; i = G[i].nxt) {
    if ((i ^ 1) == fa) continue;
    int y = G[i].to;
    if (!dfn[y]) {
      tarjan(y, i);
      low[x] = std::min(low[x], low[y]);
    } else
      low[x] = std::min(low[x], dfn[y]);
  }
  if (low[x] == dfn[x]) {
    ++cnt;
    for (int y = 0; y != x; --top) {
      y = stk[top];
      if (tarjan_tag)
        bel[y] = cnt;
      else
        Bel[y] = cnt;
    }
  }
}

std::set<std::pair<int, int>> set;

inline int check_edge(int x, int y) {
  if (x > y) std::swap(x, y);
  if (set.find({ x, y }) != set.end())
    return 0;
  set.insert({ x, y });
  return 1;
}

std::vector<int> T[N];

int ans;

inline int online(int x) {
  x = (x + ans) % n;
  if (x == 0) x = n;
  return x;
}

int dad[N][21], dep[N], root[N];
int id[N], dd;

void dfs(int x, int fa) {
  dad[x][0] = fa;
  id[x] = ++dd;
  if (!fa) root[x] = x;
  else root[x] = root[fa];
  dep[x] = dep[fa] + 1;
  for (int i = 1; i <= 20; ++i)
    dad[x][i] = dad[dad[x][i - 1]][i - 1];
  for (int y : T[x])
    if (y != fa)
      dfs(y, x);
}

inline int get_lca(int x, int y) {
  if (dep[x] < dep[y])
    std::swap(x, y);
  for (int i = 20; ~i; --i)
    if (dep[dad[x][i]] >= dep[y])
      x = dad[x][i];
  if (x == y) return x;
  for (int i = 20; ~i; --i)
    if (dad[x][i] != dad[y][i])
      x = dad[x][i], y = dad[y][i];
  return dad[x][0];
}

inline void insert(int x, int stk[], int &top) {
  if (top <= 1)
    stk[++top] = x;
  else {
    int lca = get_lca(x, stk[top]);
    if (lca != stk[top]) {
      while (top > 1 && id[stk[top - 1]] >= id[lca]) {
        addedge(stk[top - 1], stk[top]);
        addedge(stk[top], stk[top - 1]);
        --top;
      }
      if (lca != stk[top]) {
        addedge(lca, stk[top]);
        addedge(stk[top], lca);
        stk[top] = lca;
      }
    }
    stk[++top] = x;
  }
}

inline void build_vtree(std::vector<int> &pt) {
  int up = pt.size();
  for (int i = 0; i < up; ++i)
    pt.push_back(root[pt[i]]);
  std::sort(pt.begin(), pt.end());
  pt.resize(std::unique(pt.begin(), pt.end()) - pt.begin());
  std::sort(pt.begin(), pt.end(), [&](int x, int y)
    { return id[x] < id[y]; });

  /*
  for (int i : pt)
    cerr << i << " ";
  cerr << endl;
  */

  static int stk[N], top;
  top = 0;
  for (auto x : pt)
    insert(x, stk, top);
  while (top > 1) {
    addedge(stk[top - 1], stk[top]);
    addedge(stk[top], stk[top - 1]);
    --top;
  }
}

inline int check_ans(std::vector<int> &pt) {
  for (int x : pt) {
    if (!dfn[x])
      tarjan(x, 0);
    // cerr << x << endl;
  }
  /*
  if (cnt != 1)
    return 0;
  */
  int now = 0;
  for (int x : pt) {
    if (!now)
      now = Bel[x];
    else {
      if (now != Bel[x])
        return 0;
    }
  }
  return 1;
}

inline void clear(std::vector<int> &pt) {
  /*
  clear_graph();
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  num = 0;
  top = 0;
  cnt = 0;
  */
  while (graph_top) {
    int x = graph_stk[graph_top];
    --graph_top;
    head[x] = 0;
    dfn[x] = 0;
    low[x] = 0;
  }
  for (int x : pt) {
    head[x] = dfn[x] = low[x] = 0;
  }
  num = top = cnt = 0;
  etot = 1;
}

int main() {
//   freopen("data", "r", stdin);
  fread(buc_in, 1, S, stdin);
  n = rd(), m = rd(), q = rd();
  for (int i = 1; i <= m; ++i) {
    int x = rd(), y = rd();
    addedge(x, y);
    addedge(y, x);
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i, 0);

  tarjan_tag = 0;

  for (int x = 1; x <= n; ++x) {
    for (int i = head[x]; i; i = G[i].nxt) {
      int y = G[i].to;
      if (bel[x] != bel[y]) {
        if (check_edge(bel[x], bel[y])) {
          T[bel[x]].push_back(bel[y]);
          T[bel[y]].push_back(bel[x]);
        }
      }
    }
  }

  for (int i = 1; i <= cnt; ++i)
    if (!root[i])
      dfs(i, 0);

  /*
  for (int i = 1; i <= n; ++i)
    cerr << bel[i] << " ";
  cerr << endl;
  */

  clear_graph();
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  num = 0;
  top = 0;
  cnt = 0;

  for (int ver = 1; ver <= q; ++ver) {
    int n = rd(), m = rd();

    std::vector<int> pt, raw_pt;
    for (int i = 1; i <= n; ++i) {
      int x = rd();
      x = online(x);
      pt.push_back(bel[x]);
      raw_pt.push_back(bel[x]);
    }
    for (int i = 1; i <= m; ++i) {
      int x = rd(), y = rd();
      x = online(x);
      y = online(y);
      x = bel[x];
      y = bel[y];
      if (x == y)
        continue;
      addedge(x, y);
      addedge(y, x);
      pt.push_back(x);
      pt.push_back(y);
    }
    build_vtree(pt);
    int now = check_ans(raw_pt);
    if (now) {
      puts("YES");
      ans += ver;
      ans %= n;
    } else {
      puts("NO");
    }
    clear(pt);
  }
  return 0;
}


#include <bits/stdc++.h>

using std::cerr;
using std::endl;

const int S = 100000 * 20;

char buc_in[S], *p_in = buc_in;

inline int rd() {
  int b = 0;
  while (!isdigit(*p_in)) ++p_in;
  while (isdigit(*p_in)) b = b * 10 + *p_in++ - '0';
  return b;
}

const int N = 3e5 + 233;

int n, m, q;
int tarjan_tag = 1;

struct Graph {
  int to, nxt;
} G[N * 2];
int head[N], etot = 1;

int graph_stk[N], graph_top;

inline void addedge(int x, int y) {
  /*
  if (!tarjan_tag)
    cerr << x << " " << y << endl;
  */
  G[++etot] = { y, head[x] }, head[x] = etot;
  graph_stk[++graph_top] = x;
}

inline void clear_graph() {
  while (graph_top)
    head[graph_stk[graph_top--]] = 0;
  etot = 1;
}

int dfn[N], low[N], num, stk[N], top, bel[N], Bel[N], cnt;

void tarjan(int x, int fa) {
  dfn[x] = low[x] = ++num;
  stk[++top] = x;
  for (int i = head[x]; i; i = G[i].nxt) {
    if ((i ^ 1) == fa) continue;
    int y = G[i].to;
    if (!dfn[y]) {
      tarjan(y, i);
      low[x] = std::min(low[x], low[y]);
    } else
      low[x] = std::min(low[x], dfn[y]);
  }
  if (low[x] == dfn[x]) {
    ++cnt;
    for (int y = 0; y != x; --top) {
      y = stk[top];
      if (tarjan_tag)
        bel[y] = cnt;
      else
        Bel[y] = cnt;
    }
  }
}

std::set<std::pair<int, int>> set;

inline int check_edge(int x, int y) {
  if (x > y) std::swap(x, y);
  if (set.find({ x, y }) != set.end())
    return 0;
  set.insert({ x, y });
  return 1;
}

std::vector<int> T[N];

int ans;

inline int online(int x) {
  x = (x + ans) % n;
  if (x == 0) x = n;
  return x;
}

int dad[N][21], dep[N], root[N];
int id[N], dd;

void dfs(int x, int fa) {
  dad[x][0] = fa;
  id[x] = ++dd;
  if (!fa) root[x] = x;
  else root[x] = root[fa];
  dep[x] = dep[fa] + 1;
  for (int i = 1; i <= 20; ++i)
    dad[x][i] = dad[dad[x][i - 1]][i - 1];
  for (int y : T[x])
    if (y != fa)
      dfs(y, x);
}

inline int get_lca(int x, int y) {
  if (dep[x] < dep[y])
    std::swap(x, y);
  for (int i = 20; ~i; --i)
    if (dep[dad[x][i]] >= dep[y])
      x = dad[x][i];
  if (x == y) return x;
  for (int i = 20; ~i; --i)
    if (dad[x][i] != dad[y][i])
      x = dad[x][i], y = dad[y][i];
  return dad[x][0];
}

inline void insert(int x, int stk[], int &top) {
  if (top <= 1)
    stk[++top] = x;
  else {
    int lca = get_lca(x, stk[top]);
    if (lca != stk[top]) {
      while (top > 1 && id[stk[top - 1]] >= id[lca]) {
        addedge(stk[top - 1], stk[top]);
        addedge(stk[top], stk[top - 1]);
        --top;
      }
      if (lca != stk[top]) {
        addedge(lca, stk[top]);
        addedge(stk[top], lca);
        stk[top] = lca;
      }
    }
    stk[++top] = x;
  }
}

inline void build(std::vector<int> &pt, int l, int r) {
  static int stk[N], top;
  top = 0;
  for (int i = l; i <= r; ++i) {
    insert(pt[i], stk, top);
  }
  while (top > 1) {
    addedge(stk[top - 1], stk[top]);
    addedge(stk[top], stk[top - 1]);
    --top;
  }
}

inline void build_vtree(std::vector<int> &pt) {
  int up = pt.size();
  for (int i = 0; i < up; ++i)
    pt.push_back(root[pt[i]]);
  std::sort(pt.begin(), pt.end());
  pt.resize(std::unique(pt.begin(), pt.end()) - pt.begin());
  std::sort(pt.begin(), pt.end(), [&](int x, int y)
    { return id[x] < id[y]; });

  /*
  for (int x : pt)
    cerr << x << " ";
  cerr << endl;
  */

  for (int i = 0, j = 0; i < (int)pt.size(); ++i) {
    if (i + 1 < (int)pt.size() && root[pt[i]] != root[pt[i + 1]]) {
      build(pt, j, i);
      j = i + 1;
      continue;
    }
    if (i == (int)pt.size() - 1) {
      build(pt, j, i);
      continue;
    }
  }

  /*
  for (auto x : pt)
    insert(x, stk, top);
  while (top > 1) {
    addedge(stk[top - 1], stk[top]);
    addedge(stk[top], stk[top - 1]);
    --top;
  }
  */
}

inline int check_ans(std::vector<int> &pt) {
  for (int x : pt) {
    if (!dfn[x])
      tarjan(x, 0);
    // cerr << x << endl;
  }
  /*
  if (cnt != 1)
    return 0;
  */
  int now = 0;
  for (int x : pt) {
    if (!now)
      now = Bel[x];
    else {
      if (now != Bel[x])
        return 0;
    }
  }
  return 1;
}

inline void clear(std::vector<int> &pt) {
  /*
  clear_graph();
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  num = 0;
  top = 0;
  cnt = 0;
  */
  while (graph_top) {
    int x = graph_stk[graph_top];
    --graph_top;
    head[x] = 0;
    dfn[x] = 0;
    low[x] = 0;
  }
  for (int x : pt) {
    head[x] = dfn[x] = low[x] = 0;
  }
  num = top = cnt = 0;
  etot = 1;
}

int main() {
//   freopen("data", "r", stdin);
  fread(buc_in, 1, S, stdin);
  n = rd(), m = rd(), q = rd();
  for (int i = 1; i <= m; ++i) {
    int x = rd(), y = rd();
    addedge(x, y);
    addedge(y, x);
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i, 0);

  tarjan_tag = 0;

  for (int x = 1; x <= n; ++x) {
    for (int i = head[x]; i; i = G[i].nxt) {
      int y = G[i].to;
      if (bel[x] != bel[y]) {
        if (check_edge(bel[x], bel[y])) {
          T[bel[x]].push_back(bel[y]);
          T[bel[y]].push_back(bel[x]);
        }
      }
    }
  }

  for (int i = 1; i <= cnt; ++i)
    if (!root[i])
      dfs(i, 0);

  /*
  for (int i = 1; i <= n; ++i)
    cerr << bel[i] << " ";
  cerr << endl;
  */

  clear_graph();
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  num = 0;
  top = 0;
  cnt = 0;

  for (int ver = 1; ver <= q; ++ver) {
    int n = rd(), m = rd();

    std::vector<int> pt, raw_pt;
    for (int i = 1; i <= n; ++i) {
      int x = rd();
      x = online(x);
      // cerr << x << endl;
      pt.push_back(bel[x]);
      raw_pt.push_back(bel[x]);
    }
    for (int i = 1; i <= m; ++i) {
      int x = rd(), y = rd();
      x = online(x);
      y = online(y);
      // cerr << x << " " << y << endl;
      x = bel[x];
      y = bel[y];
      if (x == y)
        continue;
      addedge(x, y);
      addedge(y, x);
      pt.push_back(x);
      pt.push_back(y);
    }
    build_vtree(pt);
    int now = check_ans(raw_pt);
    if (now) {
      puts("YES");
      ans += ver;
      ans %= ::n;
    } else {
      puts("NO");
    }
    clear(pt);
  }
  return 0;
}


#include <bits/stdc++.h>

using std::cerr;
using std::endl;

const int S = 100000 * 20;

char buc_in[S], *p_in = buc_in;

inline int rd() {
  int b = 0;
  while (!isdigit(*p_in)) ++p_in;
  while (isdigit(*p_in)) b = b * 10 + *p_in++ - '0';
  return b;
}

const int N = 3e5 + 233;

int n, m, q;
int tarjan_tag = 1;

struct Graph {
  int to, nxt;
} G[N * 2];
int head[N], etot = 1;

int graph_stk[N], graph_top;

inline void addedge(int x, int y) {
  G[++etot] = { y, head[x] }, head[x] = etot;
  graph_stk[++graph_top] = x;
}

inline void clear_graph() {
  while (graph_top)
    head[graph_stk[graph_top--]] = 0;
  etot = 1;
}

int dfn[N], low[N], num, stk[N], top, bel[N], cnt;

void tarjan(int x, int fa) {
  dfn[x] = low[x] = ++num;
  stk[++top] = x;
  for (int i = head[x]; i; i = G[i].nxt) {
    if ((i ^ 1) == fa) continue;
    int y = G[i].to;
    if (!dfn[y]) {
      tarjan(y, i);
      low[x] = std::min(low[x], low[y]);
    } else
      low[x] = std::min(low[x], dfn[y]);
  }
  if (low[x] == dfn[x]) {
    ++cnt;
    for (int y = 0; y != x; --top) {
      y = stk[top];
      if (tarjan_tag)
        bel[y] = cnt;
    }
  }
}

std::set<std::pair<int, int>> set;

inline int check_edge(int x, int y) {
  if (x > y) std::swap(x, y);
  if (set.find({ x, y }) != set.end())
    return 0;
  set.insert({ x, y });
  return 1;
}

std::vector<int> T[N];

int ans;

inline int online(int x) {
  x = (x + ans) % n;
  if (x == 0) x = n;
  return x;
}

int dad[N][21], dep[N], root[N];
int id[N], dd;

void dfs(int x, int fa) {
  dad[x][0] = fa;
  id[x] = ++dd;
  if (!fa) root[x] = x;
  else root[x] = root[fa];
  dep[x] = dep[fa] + 1;
  for (int i = 1; i <= 20; ++i)
    dad[x][i] = dad[dad[x][i - 1]][i - 1];
  for (int y : T[x])
    if (y != fa)
      dfs(y, x);
}

inline int get_lca(int x, int y) {
  if (dep[x] < dep[y])
    std::swap(x, y);
  for (int i = 20; ~i; --i)
    if (dep[dad[x][i]] >= dep[y])
      x = dad[x][i];
  if (x == y) return x;
  for (int i = 20; ~i; --i)
    if (dad[x][i] != dad[y][i])
      x = dad[x][i], y = dad[y][i];
  return dad[x][0];
}

inline void insert(int x, int stk[], int &top) {
  if (top <= 1)
    stk[++top] = x;
  else {
    int lca = get_lca(x, stk[top]);
    if (lca != stk[top]) {
      while (top > 1 && id[stk[top - 1]] >= id[lca]) {
        addedge(stk[top - 1], stk[top]);
        addedge(stk[top], stk[top - 1]);
        --top;
      }
      if (lca != stk[top]) {
        addedge(lca, stk[top]);
        addedge(stk[top], lca);
        stk[top] = lca;
      }
    }
    stk[++top] = x;
  }
}

inline void build_vtree(std::vector<int> &pt) {
  int up = pt.size();
  for (int i = 0; i < up; ++i)
    pt.push_back(root[pt[i]]);
  std::sort(pt.begin(), pt.end());
  pt.resize(std::unique(pt.begin(), pt.end()) - pt.begin());
  std::sort(pt.begin(), pt.end(), [&](int x, int y)
    { return id[x] < id[y]; });

  /*
  for (int i : pt)
    cerr << i << " ";
  cerr << endl;
  */

  static int stk[N], top;
  top = 0;
  for (auto x : pt)
    insert(x, stk, top);
  while (top > 1) {
    addedge(stk[top - 1], stk[top]);
    addedge(stk[top], stk[top - 1]);
    --top;
  }
}

inline int check_ans(std::vector<int> &pt) {
  for (int x : pt)
    if (!dfn[x])
      tarjan(x, 0);
  if (cnt != 1)
    return 0;
  return 1;
}

inline void clear() {
  /*
  clear_graph();
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  num = 0;
  top = 0;
  cnt = 0;
  */
  while (graph_top) {
    int x = graph_stk[graph_top];
    --graph_top;
    head[x] = 0;
    dfn[x] = 0;
    low[x] = 0;
  }
  num = top = cnt = 0;
  etot = 1;
}

int main() {
//   freopen("data", "r", stdin);
  fread(buc_in, 1, S, stdin);
  n = rd(), m = rd(), q = rd();
  for (int i = 1; i <= m; ++i) {
    int x = rd(), y = rd();
    addedge(x, y);
    addedge(y, x);
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i, 0);

  tarjan_tag = 0;

  for (int x = 1; x <= n; ++x) {
    for (int i = head[x]; i; i = G[i].nxt) {
      int y = G[i].to;
      if (bel[x] != bel[y]) {
        if (check_edge(bel[x], bel[y])) {
          T[bel[x]].push_back(bel[y]);
          T[bel[y]].push_back(bel[x]);
        }
      }
    }
  }

  for (int i = 1; i <= cnt; ++i)
    if (!root[i])
      dfs(i, 0);

  clear_graph();
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  num = 0;
  top = 0;
  cnt = 0;

  for (int ver = 1; ver <= q; ++ver) {
    int n = rd(), m = rd();

    std::vector<int> pt, raw_pt;
    for (int i = 1; i <= n; ++i) {
      int x = rd();
      x = online(x);
      pt.push_back(bel[x]);
      raw_pt.push_back(bel[x]);
    }
    for (int i = 1; i <= m; ++i) {
      int x = rd(), y = rd();
      x = online(x);
      y = online(y);
      x = bel[x];
      y = bel[y];
      if (x == y)
        continue;
      addedge(x, y);
      addedge(y, x);
      pt.push_back(x);
      pt.push_back(y);
    }
    build_vtree(pt);
    int now = check_ans(raw_pt);
    if (now) {
      puts("YES");
      ans += ver;
      ans %= n;
    } else {
      puts("NO");
    }
    clear();
  }
  return 0;
}


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

const int N=300010;
int dfn[N],bel[N],hd[N],Hd[N],fa[N],cnt,x,y,R,n,m,q,low[N],sta[N],stp,tp[N],siz[N],T[N*3],EE[N][2],bcj[N],TT[N*6],TN,Bel[N],t[N],nn,Fa[N],Dfn[N];
struct node{int to,next;}e[N<<1],E[N<<1];
bool bo[N],Bo;

void Addedge(int x,int y)
{
	E[++cnt]=(node){y,Hd[x]},Hd[x]=cnt;
	E[++cnt]=(node){x,Hd[y]},Hd[y]=cnt;
}

void addedge(int x,int y) {e[++cnt]=(node){y,hd[x]},hd[x]=cnt;}
bool cmp(int x,int y) {return dfn[x]<dfn[y];}
int ask(int x) {return bcj[x]==x?x:bcj[x]=ask(bcj[x]);}

void tarjan(int x,int la)
{
	dfn[x]=low[x]=(++cnt),sta[++stp]=x,bo[x]=1;
	for (int i=Hd[x]; i; i=E[i].next) if (i!=(la^1))
	{
		if (!dfn[E[i].to]) tarjan(E[i].to,i),low[x]=min(low[x],low[E[i].to]);
		else if (bo[E[i].to]) low[x]=min(low[x],dfn[E[i].to]);
	}
	if (dfn[x]==low[x])
	{
		bel[x]=x,bo[x]=0;
		while (sta[stp]!=x) bel[sta[stp]]=x,bo[sta[stp]]=0,stp--;
		stp--;
	}
}

void dfs(int x)
{
	siz[x]=1;
	for (int i=hd[x]; i; i=e[i].next)
		if (e[i].to!=fa[x]) fa[e[i].to]=x,dfs(e[i].to),siz[x]+=siz[e[i].to];
}

void Dfs(int x)
{
	dfn[x]=(++cnt); int ma=0,maa;
	for (int i=hd[x]; i; i=e[i].next)
		if (e[i].to!=fa[x]&&siz[e[i].to]>ma) ma=siz[e[i].to],maa=e[i].to;
	if (!ma) return;
	tp[maa]=tp[x],Dfs(maa);
	for (int i=hd[x]; i; i=e[i].next)
		if (e[i].to!=fa[x]&&e[i].to!=maa) tp[e[i].to]=e[i].to,Dfs(e[i].to);
}

int lca(int x,int y)
{
	if (dfn[x]<dfn[y]) swap(x,y);
	while (tp[x]!=tp[y])
	{
		x=fa[tp[x]];
		if (dfn[x]<dfn[y]) swap(x,y);
	}
	return y;
}

int main()
{
	scanf("%d%d%d",&n,&m,&q),cnt=1,memset(Hd,0,sizeof(Hd));
	for (int i=1; i<=n; i++) bcj[i]=i;
	for (int i=1; i<=m; i++) scanf("%d%d",&x,&y),Addedge(x,y),bcj[ask(x)]=ask(y);
	cnt=stp=0,memset(bo,0,sizeof(bo));
	for (int i=1; i<=n; i++) if (!dfn[i]) tarjan(i,0);
	cnt=0,memset(hd,0,sizeof(hd));
	for (int i=1; i<=n; i++)
		for (int j=Hd[i]; j; j=E[j].next)
			if (bel[E[j].to]!=bel[i]) addedge(bel[i],bel[E[j].to]);
	memset(fa,0,sizeof(fa)),cnt=R=0;
	for (int i=1; i<=n; i++) if (!fa[i]) tp[i]=i,dfs(i),Dfs(i);
	memset(Hd,0,sizeof(Hd)),nn=n;
	for (int que=1; que<=q; que++)
	{
		scanf("%d%d",&n,&m);
		for (int i=1; i<=n; i++) scanf("%d",&T[i]),T[i]=bel[(T[i]+R-1)%nn+1],t[i]=T[i];
		for (int i=1; i<=m; i++) scanf("%d%d",&x,&y),EE[i][0]=bel[(x+R-1)%nn+1],EE[i][1]=bel[(y+R-1)%nn+1];
		for (int i=1; i<=m; i++) T[n+2*i-1]=EE[i][0],T[n+2*i]=EE[i][1];
		sort(T+1,T+1+n+2*m,cmp),cnt=1,sta[stp=1]=T[1],Fa[T[1]]=0,TT[TN=1]=T[1];
		for (int i=2; i<=n+2*m; i++) if (T[i]!=T[i-1])
		{
			if (ask(T[i])!=ask(T[i-1]))
			{
				for (int j=stp; j>1; j--) Fa[sta[j]]=sta[j-1];
				sta[stp=1]=T[i],Fa[T[i]]=0,TT[++TN]=T[i];
				continue;
			}
			x=T[i],y=lca(x,sta[stp]);
			while (stp>1&&siz[sta[stp-1]]<=siz[y]) Fa[sta[stp]]=sta[stp-1],stp--;
			if (siz[sta[stp]]<siz[y]) Fa[sta[stp]]=y,sta[stp]=y,Fa[y]=0,TT[++TN]=y;
			if (x!=y) sta[++stp]=x,Fa[x]=0,TT[++TN]=x;
		}
		Bo=1;
		for (int i=stp; i>1; i--) Fa[sta[i]]=sta[i-1];
		for (int i=1; i<=TN; i++) Dfn[TT[i]]=dfn[TT[i]],Hd[TT[i]]=0,dfn[TT[i]]=0,Bel[TT[i]]=bel[TT[i]];
		for (int i=1; i<=TN; i++) if (Fa[TT[i]]) Addedge(Fa[TT[i]],TT[i]);
		for (int i=1; i<=m; i++) Addedge(EE[i][0],EE[i][1]);
		for (int i=1; i<=TN; i++) if (!dfn[TT[i]]) tarjan(TT[i],0);
		for (int i=1; i<n; i++) if (bel[t[i]]!=bel[t[i+1]]) {Bo=0; break;}
		if (Bo) puts("YES"),R=(R+que)%nn; else puts("NO");
		for (int i=1; i<=TN; i++) bel[TT[i]]=Bel[TT[i]],dfn[TT[i]]=Dfn[TT[i]];
	}
	return 0;
}


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

const int N=300010;
int dfn[N],bel[N],hd[N],Hd[N],fa[N],cnt,x,y,R,n,m,q,low[N],sta[N],stp,tp[N],siz[N],T[N*3],EE[N][2],bcj[N],TT[N*6],TN,Bel[N],t[N],nn,Fa[N];
struct node{int to,next;}e[N<<1],E[N<<1];
bool bo[N],Bo;

void Addedge(int x,int y)
{
	E[++cnt]=(node){y,Hd[x]},Hd[x]=cnt;
	E[++cnt]=(node){x,Hd[y]},Hd[y]=cnt;
}

void addedge(int x,int y) {e[++cnt]=(node){y,hd[x]},hd[x]=cnt;}
bool cmp(int x,int y) {return dfn[x]<dfn[y];}
int ask(int x) {return bcj[x]==x?x:bcj[x]=ask(bcj[x]);}

void tarjan(int x,int la)
{
	dfn[x]=low[x]=(++cnt),sta[++stp]=x,bo[x]=1;
	for (int i=Hd[x]; i; i=E[i].next) if (i!=(la^1))
	{
		if (!dfn[E[i].to]) tarjan(E[i].to,i),low[x]=min(low[x],low[E[i].to]);
		else if (bo[E[i].to]) low[x]=min(low[x],dfn[E[i].to]);
	}
	if (dfn[x]==low[x])
	{
		bel[x]=x,bo[x]=0;
		while (sta[stp]!=x) bel[sta[stp]]=x,bo[sta[stp]]=0,stp--;
		stp--;
	}
}

void dfs(int x)
{
	siz[x]=1;
	for (int i=hd[x]; i; i=e[i].next)
		if (e[i].to!=fa[x]) fa[e[i].to]=x,dfs(e[i].to),siz[x]+=siz[e[i].to];
}

void Dfs(int x)
{
	dfn[x]=(++cnt); int ma=0,maa;
	for (int i=hd[x]; i; i=e[i].next)
		if (e[i].to!=fa[x]&&siz[e[i].to]>ma) ma=siz[e[i].to],maa=e[i].to;
	if (!ma) return;
	tp[maa]=tp[x],Dfs(maa);
	for (int i=hd[x]; i; i=e[i].next)
		if (e[i].to!=fa[x]&&e[i].to!=maa) tp[e[i].to]=e[i].to,Dfs(e[i].to);
}

int lca(int x,int y)
{
	if (dfn[x]<dfn[y]) swap(x,y);
	while (tp[x]!=tp[y])
	{
		x=fa[tp[x]];
		if (dfn[x]<dfn[y]) swap(x,y);
	}
	return y;
}

int main()
{
	scanf("%d%d%d",&n,&m,&q),cnt=1,memset(Hd,0,sizeof(Hd));
	for (int i=1; i<=n; i++) bcj[i]=i;
	for (int i=1; i<=m; i++) scanf("%d%d",&x,&y),Addedge(x,y),bcj[ask(x)]=ask(y);
	cnt=stp=0,memset(bo,0,sizeof(bo));
	for (int i=1; i<=n; i++) if (!dfn[i]) tarjan(i,0);
	cnt=0,memset(hd,0,sizeof(hd));
	for (int i=1; i<=n; i++)
		for (int j=Hd[i]; j; j=E[j].next)
			if (bel[E[j].to]!=bel[i]) addedge(bel[i],bel[E[j].to]);
	memset(fa,0,sizeof(fa)),cnt=R=0;
	for (int i=1; i<=n; i++) if (!fa[i]) tp[i]=i,dfs(i),Dfs(i);
	memset(Hd,0,sizeof(Hd)),nn=n;
	for (int que=1; que<=q; que++)
	{
		scanf("%d%d",&n,&m);
		for (int i=1; i<=n; i++) scanf("%d",&T[i]),T[i]=bel[(T[i]+R-1)%nn+1],t[i]=T[i];
		for (int i=1; i<=m; i++) scanf("%d%d",&x,&y),EE[i][0]=bel[(x+R-1)%nn+1],EE[i][1]=bel[(y+R-1)%nn+1];
		for (int i=1; i<=m; i++) T[n+2*i-1]=EE[i][0],T[n+2*i]=EE[i][1];
		sort(T+1,T+1+n+2*m,cmp),cnt=0,sta[stp=1]=T[1],Fa[T[1]]=0,TT[TN=1]=T[1];
		for (int i=2; i<=n+2*m; i++) if (T[i]!=T[i-1])
		{
			if (ask(T[i])!=ask(T[i-1]))
			{
				for (int j=stp; j>1; j--) Fa[sta[j]]=sta[j-1];
				sta[stp=1]=T[i],Fa[T[i]]=0,TT[++TN]=T[i];
				continue;
			}
			x=T[i],y=lca(x,sta[stp]);
			while (stp>1&&siz[sta[stp-1]]<=siz[y]) Fa[sta[stp]]=sta[stp-1],stp--;
			if (siz[sta[stp]]<siz[y]) Fa[sta[stp]]=y,sta[stp]=y,Fa[y]=0,TT[++TN]=y;
			if (x!=y) sta[++stp]=x,Fa[x]=0,TT[++TN]=x;
		}
		Bo=1;
		for (int i=stp; i>1; i--) Fa[sta[i]]=sta[i-1];
		for (int i=1; i<=TN; i++) Hd[TT[i]]=0,dfn[TT[i]]=0,Bel[TT[i]]=bel[TT[i]];
		for (int i=1; i<=TN; i++) if (Fa[TT[i]]) Addedge(Fa[TT[i]],TT[i]);
		for (int i=1; i<=m; i++) Addedge(EE[i][0],EE[i][1]);
		for (int i=1; i<=TN; i++) if (!dfn[TT[i]]) tarjan(TT[i],0);
		for (int i=1; i<n; i++) if (bel[t[i]]!=bel[t[i+1]]) {Bo=0; break;}
		if (Bo) puts("YES"),R=(R+que)%nn; else puts("NO");
		for (int i=1; i<=TN; i++) bel[TT[i]]=Bel[TT[i]];
	}
	return 0;
}


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


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