#include <bits/stdc++.h>
using namespace std;
const int N = 3e6 + 5, M = 1e3 + 5;
const long long INF = 1e18 + 5;
inline long long read() {
  long long sum = 0, fh = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') fh = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum * fh;
}
inline int read2() {
  char c = getchar();
  while (c != 'a' && c != 'b' && c != 'c' && c != '?') c = getchar();
  return c == '?' ? 0 : c - 'a' + 1;
}
inline int read3() {
  char c = getchar();
  while (c < 'a' || c > 'z') {
    c = getchar();
  }
  return c - 'a';
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
inline long long ab(long long x) { return x < 0 ? -x : x; }
inline long long fpow(long long qwe, long long asd, long long zxc) {
  if (asd < 0) return 0;
  long long a = qwe, b = 1, c = asd;
  while (c) {
    if (c & 1) b = b * a % zxc;
    a = a * a % zxc;
    c >>= 1;
  }
  return b;
}
int n, m, t;
unordered_map<bitset<M>, int> qwe, asd;
bitset<M> a[35], b, c;
inline void dfs(int l, int r, int k, int s, int x) {
  if (k == r) {
    if (x == 0) {
      int zxc = qwe[c];
      qwe[c] = (zxc ? min(zxc, s) : s);
    } else {
      int zxc = asd[c];
      asd[c] = (zxc ? min(zxc, s) : s);
    }
  } else
    dfs(l, r, k + 1, s, x);
  c ^= a[k];
  ++s;
  if (k == r) {
    if (x == 0) {
      int zxc = qwe[c];
      qwe[c] = (zxc ? min(zxc, s) : s);
    } else {
      int zxc = asd[c];
      asd[c] = (zxc ? min(zxc, s) : s);
    }
  } else
    dfs(l, r, k + 1, s, x);
  c ^= a[k];
  return;
}
int main() {
  n = read(), m = read(), t = read();
  for (int i = 1; i <= m; ++i) {
    int x = read();
    for (int j = 1; j <= x; ++j) {
      int y = read();
      a[i][y] = 1;
    }
  }
  int fj = 10;
  if (m <= fj) {
    dfs(1, m, 1, 0, 0);
    qwe[0] = 0;
    while (t) {
      --t;
      b.reset();
      int k = read();
      for (int i = 1; i <= k; ++i) {
        int x = read();
        b[x] = 1;
      }
      int ans;
      if (k == 0)
        ans = 0;
      else {
        ans = qwe[b];
        if (!ans) ans = -1;
      }
      write(ans), putchar('\n');
    }
  } else {
    dfs(1, fj, 1, 0, 0);
    qwe[0] = 0;
    dfs(fj + 1, m, fj + 1, 0, 1);
    asd[0] = 0;
    while (t) {
      --t;
      b.reset();
      int k = read();
      for (int i = 1; i <= k; ++i) {
        int x = read();
        b[x] = 1;
      }
      int ans = 998244353;
      if (k == 0) ans = 0;
      for (unordered_map<bitset<M>, int>::iterator i = qwe.begin();
           i != qwe.end(); ++i) {
        int x = (*i).second;
        c = b ^ (*i).first;
        if (c == 0)
          ans = min(ans, x);
        else {
          int y = asd[c];
          if (y != 0) ans = min(ans, x + y);
        }
      }
      if (ans == 998244353) ans = -1;
      write(ans), putchar('\n');
    }
  }
}
