#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5, M = (1 << 20) + 5, K = (1 << 10) + 5;
unordered_map<bitset<N>, int> mp;
bitset<N> b[N], tmp, tt;
int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < m; i++) {
    int k, x;
    scanf("%d", &k);
    while (k--) {
      scanf("%d", &x);
      b[i].set(x);
    }
  }
  int num = min(m, 20), mx = (1 << num) - 1;
  for (int i = 0; i <= mx; i++) {
    tmp.reset();
    int sum = 0;
    for (int j = 0; j < num; j++) {
      if (i & (1 << j)) {
        tmp ^= b[j];
        sum++;
      }
    }
    if (!mp.count(tmp) || mp[tmp] > sum) mp[tmp] = sum;
  }
  while (q--) {
    int k, x;
    scanf("%d", &k);
    tmp.reset();
    while (k--) {
      scanf("%d", &x);
      tmp.set(x);
    }
    if (m <= 20) {
      if (mp.count(tmp))
        printf("%d\n", mp[tmp]);
      else
        printf("-1\n");
      continue;
    }
    num = m - 20, mx = (1 << num) - 1;
    int ans = N;
    for (int i = 0; i <= mx; i++) {
      tt = tmp;
      int sum = 0;
      for (int j = 0; j < num; j++) {
        if (i & (1 << j)) {
          tt ^= b[j + 20];
          sum++;
        }
      }
      if (mp.count(tt)) ans = min(ans, mp[tt] + sum);
    }
    printf("%d\n", ans == N ? -1 : ans);
  }
  return 0;
}
