#include <bits/stdc++.h>
using namespace std;
const int N = 1145;
int n, m, q, k;
bitset<N> a[51], f, nw, tp, s[N];
unordered_map<bitset<N>, int> mn;
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d", &x);
    while (x--) scanf("%d", &y), a[i][y] = 1;
  }
  k = min(20, m);
  for (int i = 0; i < 1 << k; i++) {
    f.reset();
    for (int j = 1; j <= k; j++)
      if (i & (1 << (j - 1))) f ^= a[j];
    int ct = __builtin_popcount(i);
    if (!mn.count(f) || mn[f] > ct) mn[f] = ct;
  }
  for (int i = 0; i < 1 << (m - k); i++)
    for (int j = 1; j <= (m - k); j++)
      if (i & (1 << (j - 1))) s[i] ^= a[k + j];
  while (q--) {
    int x, y;
    scanf("%d", &x);
    nw.reset();
    int as = 1e7;
    if (x == 0) {
      puts("0");
      continue;
    }
    while (x--) scanf("%d", &y), nw[y] = 1;
    for (int i = 0; i < 1 << (m - k); i++) {
      int ct = __builtin_popcount(i);
      tp = nw ^ s[i];
      if (mn[tp]) as = min(as, mn[tp] + ct);
    }
    if (as == 1e7)
      puts("-1");
    else
      printf("%d\n", as);
  }
}
