#include <bits/stdc++.h>
using namespace std;
int n, s, d, pop[1 << 20];
bitset<1000> b0[1 << 10], b1[1 << 20];
unordered_map<bitset<1000>, int> m;
int main() {
  cin >> n >> s >> d;
  int K = s / 3;
  int c, x;
  for (int i = (0), ie = (s); i < ie; i++) {
    scanf("%d", &c);
    while (c--)
      scanf("%d", &x), x--, i < K ? b0[1 << i][x] = 1 : b1[1 << (i - K)][x] = 1;
  }
  for (int i = (0), ie = (1 << K); i < ie; i++)
    b0[i] = b0[i & (i - 1)] ^ b0[i & -i];
  for (int i = (0), ie = (1 << (s - K)); i < ie; i++) {
    b1[i] = b1[i & (i - 1)] ^ b1[i & -i];
    pop[i] = __builtin_popcount(i);
    if (m.count(b1[i]))
      m[b1[i]] = min(m[b1[i]], pop[i]);
    else
      m[b1[i]] = pop[i];
  }
  while (d--) {
    bitset<1000> nw;
    int as = 100;
    for (scanf("%d", &c); c--; scanf("%d", &x), nw[--x] = 1)
      ;
    for (int i = (0), ie = (1 << K); i < ie; i++)
      if (m.count(nw ^ b0[i])) as = min(as, pop[i] + m[nw ^ b0[i]]);
    printf("%d\n", as < 100 ? as : -1);
  }
  return 0;
}
