#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;
void printlist(vector<int> const& lst) {
  for (auto i : lst) cout << i;
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int n, s, d;
  cin >> n >> s >> d;
  int ns = n / 64 + 1;
  vector<vector<long long>> switches(s, vector<long long>(ns));
  for (int i = 0; i < s; ++i) {
    int c;
    cin >> c;
    switches[i].resize(c);
    for (int j = 0; j < c; ++j) {
      int x;
      cin >> x;
      --x;
      switches[i][x / 64] ^= (1 << (x % 64));
    }
  }
  int mid = min(s / 2, 10);
  int rem = s - mid;
  map<vector<long long>, int> left;
  for (int mask = 0; mask < (1 << mid); ++mask) {
    vector<long long> here(ns);
    int popcount = 0;
    for (int bit = 0; bit < mid; ++bit) {
      if ((mask >> bit) & 1) {
        for (int i = 0; i < ns; ++i) {
          here[i] ^= switches[bit][i];
        }
        ++popcount;
      }
    }
    if (!left.count(here))
      left[here] = popcount;
    else
      left[here] = min(left[here], popcount);
  }
  map<vector<long long>, int> right;
  for (int mask = 0; mask < (1 << rem); ++mask) {
    vector<long long> here(ns);
    int popcount = 0;
    for (int bit = 0; bit < rem; ++bit) {
      if ((mask >> bit) & 1) {
        for (int i = 0; i < ns; ++i) {
          here[i] ^= switches[mid + bit][i];
        }
        ++popcount;
      }
    }
    if (!right.count(here))
      right[here] = popcount;
    else
      right[here] = min(right[here], popcount);
  }
  for (int i = 0; i < d; ++i) {
    vector<long long> day(ns);
    int t;
    cin >> t;
    for (int j = 0; j < t; ++j) {
      int val;
      cin >> val;
      --val;
      day[val / 64] ^= (1 << (val % 64));
    }
    int res = INT_MAX;
    for (auto& [comb, req] : left) {
      vector<long long> qright(ns);
      for (int j = 0; j < qright.size(); ++j) qright[j] = comb[j] ^ day[j];
      if (right.count(qright)) res = min(res, req + right[qright]);
    }
    cout << (res == INT_MAX ? -1 : res) << '\n';
  }
}
