#include <bits/stdc++.h>
using namespace std;
const int R = 1000;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n, s, d;
  cin >> n >> s >> d;
  vector<bitset<R>> a(s);
  for (int i = 0, k, x; i < s; ++i) {
    cin >> k;
    while (k--) cin >> x, a[i][x - 1] = 1;
  }
  vector<pair<int, bitset<R>>> f1;
  int m = min(s, 10);
  for (int i = 0; i < 1 << m; ++i) {
    f1.push_back({0, {}});
    for (int j = 0; j < m; ++j)
      if (i >> j & 1) ++f1.back().first, f1.back().second ^= a[j];
  }
  unordered_map<bitset<R>, int> mp;
  int m2 = s - m;
  for (int i = 0; i < 1 << m2; ++i) {
    bitset<R> b;
    int c = 0;
    for (int j = 0; j < m2; ++j)
      if (i >> j & 1) ++c, b ^= a[m + j];
    if (!mp.count(b))
      mp[b] = c;
    else
      mp[b] = min(mp[b], c);
  }
  for (int k, x; d--;) {
    cin >> k;
    bitset<R> b;
    while (k--) cin >> x, b[x - 1] = 1;
    int ans = 1 << 30;
    for (auto &i : f1) {
      b ^= i.second;
      if (mp.count(b)) ans = min(ans, i.first + mp[b]);
      b ^= i.second;
    }
    if (ans == 1 << 30) ans = -1;
    cout << ans << "\n";
  }
  return 0;
}
