#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  int n, s, d;
  scanf("%d%d%d", &n, &s, &d);
  const int sz = 1001;
  vector<bitset<sz>> ls, rs;
  int mid = (s * 3 / 10);
  for (int i = 0; i < s; i++) {
    bitset<sz> cur;
    int c;
    scanf("%d", &c);
    for (int j = 0; j < c; j++) {
      int x;
      scanf("%d", &x);
      cur[x] = 1;
    }
    if (i < mid) {
      ls.push_back(cur);
    } else {
      rs.push_back(cur);
    }
  }
  unordered_map<bitset<sz>, int> dis1, dis2;
  auto collect = [&](vector<bitset<sz>>& switches,
                     unordered_map<bitset<sz>, int>& dis) {
    int n = (int)switches.size();
    vector<bitset<sz>> all(1 << n);
    bitset<sz> cur;
    dis[cur] = 0;
    all[0] = cur;
    for (int i = 1; i < (1 << n); i++) {
      for (int j = 0; j < n; j++) {
        if ((i >> j) & 1) {
          bitset<sz> now = all[i ^ (1 << j)] ^ switches[j];
          all[i] = now;
          int bits = __builtin_popcount(i);
          if (!dis.count(now) || dis[now] > bits) {
            dis[now] = bits;
          }
          break;
        }
      }
    }
  };
  collect(ls, dis1);
  collect(rs, dis2);
  for (int i = 0; i < d; i++) {
    bitset<sz> cur;
    int c;
    scanf("%d", &c);
    for (int i = 0; i < c; i++) {
      int x;
      scanf("%d", &x);
      cur[x] = 1;
    }
    int ans = INT_MAX;
    for (const auto& config : dis1) {
      auto to = cur ^ config.first;
      if (dis2.count(to)) {
        ans = min(ans, config.second + dis2[to]);
      }
    }
    printf("%d\n", (ans == INT_MAX ? -1 : ans));
  }
  return 0;
}
