#include <bits/stdc++.h>
using namespace std;
namespace IO {
const int sz = 1 << 15;
char inbuf[sz], outbuf[sz];
char *pinbuf = inbuf + sz;
char *poutbuf = outbuf;
inline char _getchar() {
  if (pinbuf == inbuf + sz) fread(inbuf, 1, sz, stdin), pinbuf = inbuf;
  return *(pinbuf++);
}
inline void _putchar(char x) {
  if (poutbuf == outbuf + sz) fwrite(outbuf, 1, sz, stdout), poutbuf = outbuf;
  *(poutbuf++) = x;
}
inline void flush() {
  if (poutbuf != outbuf)
    fwrite(outbuf, 1, poutbuf - outbuf, stdout), poutbuf = outbuf;
}
}  // namespace IO
inline int read() {
  int v = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    v = v * 10 + c - '0';
    c = getchar();
  }
  return v * f;
}
const int Maxn = 1005;
int N, S, D;
struct bs {
  unsigned long long v[16];
  bs() { memset(v, 0, sizeof(v)); }
  void Set(int pos, int val = 1) {
    if (val) {
      v[pos >> 6] |= 1ull << (pos & 63);
    } else {
      v[pos >> 6] &= ~(1ull << (pos & 63));
    }
  }
  void Xor(bs &b) {
    for (int i = 0; i < 16; i++) v[i] ^= b.v[i];
  }
  unsigned long long Hash() {
    unsigned long long ret = 0;
    for (int i = 0; i < 16; i++) ret = ret * 11451419191ull + v[i];
    return ret;
  }
};
bs A[35];
bs H[1048576], G[1024];
int pc[1048576];
map<unsigned long long, int> Mn;
int main() {
  N = read();
  S = read();
  D = read();
  for (int i = 0; i < S; i++) {
    int x = read();
    while (x--) {
      int y = read();
      A[i].Set(y);
    }
  }
  int L1 = min(S, 10), L2 = S - L1;
  vector<bs> V;
  for (int i = 0; i < (1 << L1); i++) {
    bs tmp;
    for (int j = 0; j < L1; j++) {
      if (i >> j & 1) {
        tmp.Xor(A[j]);
      }
    }
    G[i] = tmp;
  }
  for (int i = 1; i < (1 << L2); i++) {
    for (int j = 0; j < L2; j++) {
      if (i >> j & 1) {
        H[i] = H[i ^ (1 << j)];
        H[i].Xor(A[j + L1]);
        break;
      }
    }
  }
  for (int i = 1; i < 1048576; i++) {
    pc[i] = pc[i & (i - 1)] + 1;
  }
  for (int i = (1 << L2) - 1; i >= 0; i--) {
    Mn[H[i].Hash()] = pc[i];
  }
  while (D--) {
    int x = read();
    bs t;
    while (x--) {
      int y = read();
      t.Set(y);
    }
    int ans = 1e9;
    for (int i = 0; i < (1 << L1); i++) {
      t.Xor(G[i]);
      unsigned long long tmp = t.Hash();
      if (Mn.count(tmp)) {
        ans = min(ans, pc[i] + Mn[tmp]);
      }
      t.Xor(G[i]);
    }
    if (ans == 1e9) {
      printf("-1\n");
    } else {
      printf("%d\n", ans);
    }
  }
}
