#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
unordered_map<bitset<maxn>, int> ma, flag;
bitset<maxn> s[35];
int t1, t2;
void dfs1(bitset<maxn> z, int cost, int pos) {
  if (pos > t1 + t2) {
    if (flag[z] == 0)
      ma[z] = cost;
    else
      ma[z] = min(ma[z], cost);
    flag[z] = 1;
    return;
  }
  dfs1(z ^ s[pos], cost + 1, pos + 1);
  dfs1(z, cost, pos + 1);
}
int dfs2(bitset<maxn> z, int cost, int pos) {
  int res = 1e9;
  if (flag[z] != 0) res = cost + ma[z];
  if (pos <= t1) {
    res = min(res, dfs2(z ^ s[pos], cost + 1, pos + 1));
    res = min(res, dfs2(z, cost, pos + 1));
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, d;
  cin >> n >> m >> d;
  t1 = m / 3;
  t2 = m - t1;
  for (int i = 1; i <= m; i++) {
    int cnt;
    cin >> cnt;
    for (int j = 1; j <= cnt; j++) {
      int x;
      cin >> x;
      s[i][x] = 1;
    }
  }
  bitset<maxn> tmp;
  dfs1(tmp, 0, t1 + 1);
  while (d--) {
    int cnt;
    cin >> cnt;
    bitset<maxn> q;
    for (int i = 1; i <= cnt; i++) {
      int x;
      cin >> x;
      q[x] = 1;
    }
    int ans = dfs2(q, 0, 1);
    if (ans == 1e9)
      cout << -1 << '\n';
    else
      cout << ans << '\n';
  }
  return 0;
}
