#include <bits/stdc++.h>
long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; }
long long LCM(long long a, long long b) { return a / GCD(a, b) * b; }
long long Factorial(long long n) {
  long long m = 1;
  while (n >= 1) m *= n--;
  return m;
}
long long modPow(long long x, long long n, long long mod = 1000000007LL) {
  return (!n       ? 1
          : !n % 2 ? modPow(x * x, n / 2, mod) % mod
                   : x % mod * modPow(x, n - 1, mod) % mod);
}
long long GetDigit(long long num) {
  long long digit = 0;
  while (num != 0) {
    num /= 10;
    digit++;
  }
  return digit;
}
using namespace std;
int main(void) {
  long long N, M;
  cin >> N >> M;
  bool b[N][M];
  for (long long(i) = 0; (i) < (N); (i)++)
    for (long long(j) = 0; (j) < (M); (j)++) b[i][j] = false;
  int s;
  for (long long(i) = 0; (i) < (M); (i)++) {
    long long k;
    cin >> k;
    for (long long(j) = 0; (j) < (k); (j)++) {
      cin >> s;
      s--;
      b[i][s] = true;
    }
  }
  long long p[M];
  for (long long(i) = 0; (i) < (M); (i)++) cin >> p[i];
  long long cnt = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    for (long long(i) = 0; (i) < (N); (i)++) {
      long long cnt2 = 0;
      for (long long(j) = 0; (j) < (M); (j)++) {
        if (bit & (1 << j))
          if (b[i][j]) cnt2++;
      }
      if (cnt2 % 2 != p[i]) break;
      if (i == N - 1) cnt++;
    }
  }
  cout << cnt;
}
