#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
using namespace std;
using ll = long long int;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, s, q;
  cin >> n >> s >> q;
  vector<bitset<1000>> B(30);
  for (int i = 0; i < s; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int pos;
      cin >> pos;
      B[i][pos - 1] = 1;
    }
  }
  unordered_map<bitset<1000>, int> Least;
  Least.max_load_factor(0.25);
  const int SZ = 20;
  for (int mask = 0; mask < 1 << SZ; ++mask) {
    bitset<1000> cur;
    for (int bit = 0; bit < SZ; ++bit)
      if (mask & (1 << bit)) cur ^= B[bit];
    auto &v = Least[cur];
    v = v == 0 ? __builtin_popcount(mask) + 1
               : min(__builtin_popcount(mask) + 1, v);
  }
  while (q--) {
    bitset<1000> qry;
    int k;
    cin >> k;
    for (int i = 0; i < k; ++i) {
      int x;
      cin >> x;
      qry[x - 1] = 1;
    }
    int ans = 31;
    for (int mask = 0; mask < 1 << (30 - SZ); ++mask) {
      bitset<1000> cur;
      for (int bit = 0; bit < 30 - SZ; ++bit)
        if (mask & (1 << bit)) cur ^= B[bit + SZ];
      if (Least.find(cur ^ qry) != Least.end())
        ans = min(ans, Least[cur ^ qry] - 1 + __builtin_popcount(mask));
    }
    if (ans == 31) ans = -1;
    cout << ans << '\n';
  }
}
