#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool upmin(T &x, T y) {
  return y <= x ? x = y, 1 : 0;
}
template <typename T>
inline bool upmax(T &x, T y) {
  return x <= y ? x = y, 1 : 0;
}
const long double eps = 1e-9;
const long double pi = acos(-1);
const int oo = 1 << 30;
const long long loo = (1ll << 62) - 1;
const int MAXN = 400005;
const int MX = 400000;
const int INF = 0x3f3f3f3f;
namespace FastIO {
constexpr int SIZE = (1 << 21) + 1;
int num = 0, f;
char ibuf[SIZE], obuf[SIZE], que[65], *iS, *iT, *oS = obuf,
                                                *oT = obuf + SIZE - 1, c;
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char c) {
  *oS++ = c;
  if (oS == oT) flush();
}
inline void getc(char &c) {
  for (c = (iS == iT ? (iT = ((iS = ibuf) + fread(ibuf, 1, SIZE, stdin)),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       !isalpha(c) && c != EOF;
       c = (iS == iT ? (iT = ((iS = ibuf) + fread(ibuf, 1, SIZE, stdin)),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    ;
}
inline void reads(char *st) {
  char c;
  int n = 0;
  getc(st[++n]);
  for (c = (iS == iT ? (iT = ((iS = ibuf) + fread(ibuf, 1, SIZE, stdin)),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       isalpha(c);
       c = (iS == iT ? (iT = ((iS = ibuf) + fread(ibuf, 1, SIZE, stdin)),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    st[++n] = c;
  st[++n] = '\0';
}
template <class I>
inline void read(I &x) {
  for (f = 1, c = (iS == iT ? (iT = ((iS = ibuf) + fread(ibuf, 1, SIZE, stdin)),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = ((iS = ibuf) + fread(ibuf, 1, SIZE, stdin)),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') f = -1;
  for (x = 0; c >= '0' && c <= '9';
       c = (iS == iT ? (iT = ((iS = ibuf) + fread(ibuf, 1, SIZE, stdin)),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = (x << 3) + (x << 1) + (c & 15);
  x *= f;
}
template <class I>
inline void print(I x) {
  if (x < 0) putc('-'), x = -x;
  if (!x) putc('0');
  while (x) que[++num] = x % 10 + 48, x /= 10;
  while (num) putc(que[num--]);
}
inline void putstr(string st) {
  for (int i = 0; i < (int)st.size(); ++i) putc(st[i]);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_Flusher_;
}  // namespace FastIO
using FastIO ::print;
using FastIO ::putc;
using FastIO ::putstr;
using FastIO ::read;
using FastIO ::reads;
bitset<1005> g[1 << 18], f[1 << 12], a[1005], Q;
int n, S, Case;
unordered_map<bitset<1005>, int> Map;
signed main() {
  int n, S, Case;
  read(n), read(S), read(Case);
  for (int i = 0; i < S; ++i) {
    int num, x;
    read(num);
    a[i].reset();
    while (num--) read(x), a[i].set(x - 1, 1);
  }
  int N = S >> 1, _N = S - N;
  if (S > 20) {
    N = 18, _N = S - N;
  }
  f[0].reset(), Map[f[0]] = 0;
  for (int i = 1; i < 1 << N; ++i)
    for (int j = 0; j < N; ++j)
      if ((i >> j) & 1) {
        f[i] = f[i ^ (1 << j)] ^ a[j];
        if (Map.find(f[i]) == Map.end())
          Map[f[i]] = __builtin_popcount(i);
        else
          Map[f[i]] = min(Map[f[i]], __builtin_popcount(i));
        break;
      }
  g[0].reset();
  for (int i = 1; i < 1 << _N; ++i)
    for (int j = 0; j < _N; ++j)
      if ((i >> j) & 1) {
        g[i] = g[i ^ (1 << j)] ^ a[j + N];
        break;
      }
  while (Case--) {
    int num, x, ans = INF;
    read(num);
    Q.reset();
    while (num--) read(x), Q.set(x - 1, 1);
    for (int i = 0; i < 1 << _N; ++i)
      if (Map.find(Q ^ g[i]) != Map.end())
        upmin(ans, __builtin_popcount(i) + Map[Q ^ g[i]]);
    print(ans == INF ? -1 : ans), putc('\n');
  }
  return 0;
}
