#include <bits/stdc++.h>
using namespace std;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
const long long INF = 1e18;
const int MAX = 1005;
vector<int> sw[32];
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand(long long a, long long b) {
  return uniform_int_distribution<long long>(a, b)(rng);
}
int main() {
  int n, s, d;
  scanf("%d%d%d", &n, &s, &d);
  long long hash[n];
  for (int i = 0; i < n; i++) hash[i] = rand(1, INF);
  for (int i = 0; i < s; i++) {
    int k;
    scanf("%d", &k);
    while (k--) {
      int x;
      scanf("%d", &x);
      sw[i].push_back(x - 1);
    }
  }
  unordered_map<long long, int, custom_hash> left_sz;
  int left = s / 2;
  for (int mask = 0; mask < (1 << left); mask++) {
    long long cur = 0;
    for (int bit = 0; bit < left; bit++) {
      if (!((mask >> bit) & 1)) continue;
      for (int x : sw[bit]) cur ^= hash[x];
    }
    if (!left_sz.count(cur))
      left_sz[cur] = __builtin_popcountll(mask);
    else
      left_sz[cur] = min(left_sz[cur], __builtin_popcountll(mask));
  }
  unordered_map<long long, int, custom_hash> right_sz;
  int right = s - left;
  for (int mask = 0; mask < (1 << right); mask++) {
    long long cur = 0;
    for (int bit = 0; bit < right; bit++) {
      if (!((mask >> bit) & 1)) continue;
      for (int x : sw[bit + left]) cur ^= hash[x];
    }
    if (!right_sz.count(cur))
      right_sz[cur] = __builtin_popcountll(mask);
    else
      right_sz[cur] = min(right_sz[cur], __builtin_popcountll(mask));
  }
  while (d--) {
    long long cur = 0;
    int sz;
    scanf("%d", &sz);
    for (int i = 0; i < sz; i++) {
      int x;
      scanf("%d", &x);
      cur ^= hash[x - 1];
    }
    int ans = 100;
    for (auto p : left_sz) {
      long long tmp = cur ^ p.first;
      if (right_sz.count(tmp)) ans = min(ans, p.second + right_sz[tmp]);
      if (left_sz.count(tmp)) {
        if (tmp == p.first)
          ans = 0;
        else
          ans = min(ans, p.second + left_sz[tmp]);
      }
    }
    if (ans == 100)
      printf("-1\n");
    else
      printf("%d\n", ans);
  }
  return 0;
}
