#include <bits/stdc++.h>
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  unsigned r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a / g * b;
}
bool prime(long long n) {
  for (long long i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return false;
  }
  return n != 1;
}
map<long long, long long> prime_factor(long long n) {
  map<long long, long long> ret;
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const long double PI = 3.14159265359;
const long long MAX_N = 100010;
bool s[11];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> a(m);
  for (long long i = 0; i < (m); i++) {
    long long k;
    cin >> k;
    a[i].resize(k);
    for (long long j = 0; j < (k); j++) {
      cin >> a[i][j];
    }
  }
  vector<long long> p(m);
  for (long long i = 0; i < (m); i++) cin >> p[i];
  long long ans = 0;
  for (long long bit = 0; bit < (1 << n); bit++) {
    for (long long i = 0; i < (11); i++) s[i] = false;
    for (long long i = 0; i < (n); i++) {
      if (bit & (1 << i)) {
        s[i] = true;
      }
    }
    bool ok = true;
    for (long long i = 0; i < (m); i++) {
      long long cnt = 0;
      for (long long j = 0; j < (a[i].size()); j++) {
        if (s[j]) cnt++;
      }
      if (cnt % 2 != p[i]) {
        ok = false;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
