Limak is a smart brown bear who loves chemistry, reactions and transforming elements.

In Bearland (Limak's home) there are n elements, numbered 1 through n. There are also special machines, that can transform elements. Each machine is described by two integers ai, bi representing two elements, not necessarily distinct. One can use a machine either to transform an element ai to bi or to transform bi to ai. Machines in Bearland aren't very resistant and each of them can be used at most once. It is possible that ai = bi and that many machines have the same pair ai, bi.

Radewoosh is Limak's biggest enemy and rival. He wants to test Limak in the chemistry. They will meet tomorrow and both of them will bring all their machines. Limak has m machines but he doesn't know much about his enemy. They agreed Radewoosh will choose two distinct elements, let's denote them as x and y. Limak will be allowed to use both his and Radewoosh's machines. He may use zero or more (maybe even all) machines to achieve the goal, each machine at most once. Limak will start from an element x and his task will be to first get an element y and then to again get an element x — then we say that he succeeds. After that Radewoosh would agree that Limak knows the chemistry (and Radewoosh would go away).

Radewoosh likes some particular non-empty set of favorite elements and he will choose x, y from that set. Limak doesn't know exactly which elements are in the set and also he doesn't know what machines Radewoosh has. Limak has heard q gossips (queries) though and each of them consists of Radewoosh's machines and favorite elements. For each gossip Limak wonders if he would be able to succeed tomorrow for every pair x, y chosen from the set of favorite elements. If yes then print "YES" (without the quotes). But if there exists a pair (x, y) from the given set that Limak wouldn't be able to succeed then you should print "NO" (without the quotes).

Input

The first line contains three integers n, m and q (1 ≤ n, q ≤ 300 000, 0 ≤ m ≤ 300 000) — the number of elements, the number of Limak's machines and the number of gossips, respectively.

Each of the next m lines contains two integers ai and bi (1 ≤ ai, bi ≤ n) describing one of Limak's machines.

Then, the description of q gossips follows.

The first line of the description of the i-th gossip contains two integers ni and mi (1 ≤ ni ≤ 300 000, 0 ≤ mi ≤ 300 000). The second line contains ni distinct integers xi, 1, xi, 2, ..., xi, ni (1 ≤ xi, j ≤ n) — Radewoosh's favorite elements in the i-th gossip. Note that ni = 1 is allowed, in this case there are no pairs of distinct elements, so Limak automatically wins (the answer is "YES"). Then mi lines follow, each containing two integers ai, j, bi, j (1 ≤ ai, j, bi, j) describing one of Radewoosh's machines in the i-th gossip.

The sum of ni over all gossips won't exceed 300 000. Also, the sum of mi over all gossips won't exceed 300 000.

Important: Because we want you to process the gossips online, in order to know the elements in Radewoosh's favorite set and elements that his machines can transform, for on each number that denotes them in the input you should use following function:
    
    
    int rotate(int element)  
    {  
       element=(element+R)%n;  
      
       if (element==0) {  
           element=n;  
       }  
      
       return element;  
    }  
    

where R is initially equal to 0 and is increased by the number of the query any time the answer is "YES". Queries are numbered starting with 1 in the order they appear in the input.

Output

You should print q lines. The i-th of them should contain "YES" (without quotes) if for the i-th gossip for each pair of elements x and y (in the set xi, 1, xi, 2, ..., xi, ni) Limak is able to succeed. Otherwise you should print "NO" (without quotes).

Examples

Input

6 5 4
1 2
2 3
3 4
2 4
5 6
2 0
4 2
2 1
6 2
3 4
3 2
6 3 4
2 5
4 6
2 1
1 2
1 2


Output

YES
NO
YES
YES


Input

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


Output

NO
YES

Note

Lets look at first sample:

In first gossip Radewoosh's favorite set is {4, 2} and he has no machines. Limak can tranform element 4 into 2 (so half of a task is complete) and then 2 into 3, and 3 into 4. Answer is "YES", so R is increased by 1.

In second gossip set in the input is denoted by {6, 2} and machine by (3, 4), but R is equal to 1, so set is {1, 3} and machine is (4, 5). Answer is "NO", so R isn't changed.

In third gossip set {6, 4, 3} and machines (2, 5) and (4, 6) are deciphered to be {1, 5, 4}, (3, 6) and (5, 1).

Consider Radewoosh's choices: 

  * If he chooses elements 1 and 5, then Limak is able to transform 1 into 5, then 6 into 3, 3 into 2 and 2 into 1.
  * If he chooses elements 5 and 4, then Limak is able to transform 5 into 6, 6 into 3, 3 into 4 (half way already behind him), 4 into 2, 2 into 1, 1 into 5.
  * If he chooses elements 1 and 4, then Limak is able to transform 1 into 2, 2 into 4, 4 into 3, 3 into 6, 6 into 5 and 5 into 1. 



So Limak is able to execute task. Answer is "YES" and R is increased by 3 (it's equal to 4 now).

In last gossip {1, 2} and (1, 2) are deciphered to be {5, 6} and (5, 6). Now there are 2 machines (5, 6) so Limak is able to execute task again.
#include <bits/stdc++.h>
using namespace std;
namespace io {
const int N = 1 << 20;
char buf[N], *t1 = buf, *t2 = buf;
inline int read() {
  static int an;
  an = 0;
  static char ch;
  ch = t1 == t2 && (t2 = (t1 = buf) + fread(buf, 1, N, stdin), t1 == t2)
           ? EOF
           : *t1++;
  while (ch < 48 || ch > 57)
    ch = t1 == t2 && (t2 = (t1 = buf) + fread(buf, 1, N, stdin), t1 == t2)
             ? EOF
             : *t1++;
  while (ch >= 48 && ch <= 57)
    an = (an << 3) + (an << 1) + (ch ^ 48),
    ch = t1 == t2 && (t2 = (t1 = buf) + fread(buf, 1, N, stdin), t1 == t2)
             ? EOF
             : *t1++;
  return an;
}
}  // namespace io
using io::read;
struct graph {
  struct bian {
    int nxt, to;
  } bi[600060];
  int head[300030], num;
  inline void add(int from, int to) {
    bi[++num] = bian{head[from], to};
    head[from] = num;
  }
  int dfn[300030], low[300030], dfnum, st[300030], tp, bl[300030], cnt;
  void tarjan(int v, int fb) {
    dfn[v] = low[v] = ++dfnum, st[++tp] = v;
    for (int i = head[v], u; i; i = bi[i].nxt) {
      if ((i + 1) / 2 == (fb + 1) / 2) continue;
      u = bi[i].to;
      if (!dfn[u]) {
        tarjan(u, i);
        if (low[u] < low[v]) low[v] = low[u];
      } else if (dfn[u] < low[v])
        low[v] = dfn[u];
    }
    if (low[v] == dfn[v]) {
      bl[v] = ++cnt;
      while (st[tp] ^ v) bl[st[tp--]] = cnt;
      --tp;
    }
  }
} G, g;
struct tree {
  struct bian {
    int nxt, to;
  } bi[600060];
  int head[300030], num, siz[300030], zson[300030], tp[300030], f[300030],
      dep[300030], id[300030], idnum, dy[300030], rt[300030];
  inline void add(int from, int to) {
    bi[++num] = bian{head[from], to};
    head[from] = num;
  }
  void dfs1(int v, int fa) {
    id[v] = ++idnum;
    dy[idnum] = v;
    siz[v] = 1;
    f[v] = fa;
    dep[v] = dep[fa] + 1;
    rt[v] = rt[fa];
    for (int i = head[v], u; i; i = bi[i].nxt) {
      u = bi[i].to;
      if (u == fa) continue;
      dfs1(u, v);
      siz[v] += siz[u];
      if (siz[u] > siz[zson[v]]) zson[v] = u;
    }
  }
  void dfs2(int v, int topp) {
    tp[v] = topp;
    if (zson[v]) dfs2(zson[v], topp);
    for (int i = head[v], u; i; i = bi[i].nxt) {
      u = bi[i].to;
      if (u == f[v] || u == zson[v]) continue;
      dfs2(u, u);
    }
  }
  inline int lca(int x, int y) {
    while (tp[x] != tp[y]) {
      if (dep[tp[x]] < dep[tp[y]])
        y = f[tp[y]];
      else
        x = f[tp[x]];
    }
    if (dep[x] < dep[y])
      return x;
    else
      return y;
  }
} T;
int n, q, m, n1, m1, R, p[300030];
bool vis[300030];
int st[300030], tp, a[300030], cnt, acnt, fa[300030], f[300030];
inline bool cmp(int x, int y) { return T.id[x] < T.id[y]; }
int find(int x) {
  if (x != f[x]) return f[x] = find(f[x]);
  return x;
}
void merge(int x, int y) {
  int s = T.dy[lower_bound(a + 1, a + 1 + acnt, T.id[x]) - a],
      t = T.dy[upper_bound(a + 1, a + 1 + acnt, T.id[y]) - a - 1];
  if (T.id[x] <= T.id[s] && T.id[s] <= T.id[y] && T.id[x] <= T.id[t] &&
      T.id[t] <= T.id[y])
    while (find(t) != find(s)) f[find(t)] = find(fa[find(t)]);
}
int main() {
  n = read(), m = read(), q = read();
  int x, y;
  for (int i = 1; i <= m; ++i) {
    x = read(), y = read();
    G.add(x, y), G.add(y, x);
  }
  for (int i = 1; i <= n; ++i)
    if (!G.dfn[i]) G.tarjan(i, 0);
  for (int i = 1; i <= n; ++i)
    for (int j = G.head[i]; j; j = G.bi[j].nxt)
      if (G.bl[i] != G.bl[G.bi[j].to]) T.add(G.bl[i], G.bl[G.bi[j].to]);
  for (int i = 1; i <= G.cnt; ++i)
    if (!T.dep[i]) T.rt[0] = i, T.dfs1(i, 0);
  for (int i = 1; i <= G.cnt; ++i)
    if (T.dep[i] == 1) T.dfs2(i, i);
  for (int t = 1; t <= q; ++t) {
    n1 = read(), m1 = read();
    for (int i = 1; i <= n1; ++i) {
      x = p[i] = G.bl[(read() + R - 1) % n + 1];
      if (!vis[x]) vis[x] = 1, a[++cnt] = x;
    }
    for (int i = 1; i <= m1; ++i) {
      x = G.bl[(read() + R - 1) % n + 1], y = G.bl[(read() + R - 1) % n + 1];
      g.add(x, y), g.add(y, x);
      if (!vis[x]) vis[x] = 1, a[++cnt] = x;
      if (!vis[y]) vis[y] = 1, a[++cnt] = y;
    }
    sort(a + 1, a + 1 + cnt, cmp);
    acnt = cnt;
    tp = 0;
    for (int i = 1; i <= cnt; ++i) {
      if (!tp || T.rt[st[tp]] != T.rt[a[i]]) {
        while (tp > 1)
          g.add(st[tp - 1], st[tp]), g.add(st[tp], st[tp - 1]), --tp;
        st[tp = 1] = T.rt[a[i]];
        if (!vis[T.rt[a[i]]])
          vis[T.rt[a[i]]] = 1, a[++acnt] = T.rt[a[i]];
        else
          continue;
      }
      int l = T.lca(a[i], st[tp]);
      while (T.id[st[tp]] > T.id[l]) {
        if (T.id[st[tp - 1]] >= T.id[l]) {
          g.add(st[tp - 1], st[tp]), g.add(st[tp], st[tp - 1]);
          --tp;
        } else {
          g.add(l, st[tp]), g.add(st[tp], l);
          st[tp] = l;
          a[++acnt] = l;
        }
      }
      st[++tp] = a[i];
    }
    while (tp > 1) g.add(st[tp - 1], st[tp]), g.add(st[tp], st[tp - 1]), --tp;
    for (int i = 1; i <= acnt; ++i)
      if (!g.dfn[a[i]]) g.tarjan(a[i], 0);
    bool flag = 0;
    for (int i = 2; i <= n1; ++i)
      if (g.bl[p[i]] != g.bl[p[1]]) {
        flag = 1;
        break;
      }
    if (flag)
      printf("NO\n");
    else
      printf("YES\n"), (R += t) >= n ? R -= n : 0;
    for (int i = 1; i <= acnt; ++i)
      vis[a[i]] = g.head[a[i]] = g.dfn[a[i]] = g.low[a[i]] = 0;
    g.num = 0;
    g.cnt = 0;
    g.dfnum = 0;
    cnt = 0;
  }
  return 0;
}
