#include <bits/stdc++.h>
using namespace std;
bool is_prime(int n) {
  bool res = true;
  if (n == 1)
    return false;
  else if (n == 2)
    return true;
  else {
    for (int i = 2; i * i <= n; i++) {
      if (n % i == 0) {
        res = false;
        break;
      }
    }
  }
  return res;
}
int BinarySearch(vector<int> vec, int key) {
  int left = 0;
  int right = vec.size();
  while (left < right) {
    int mid = (left + right) / 2;
    if (vec[mid] == key)
      return mid;
    else if (mid < key)
      left = mid - 1;
    else
      right = mid + 1;
  }
  return -1;
}
bool check(long long x) {
  bool res = false;
  return res;
}
long long meguru() {
  long long ok = 1e10;
  long long ng = -1;
  while (abs(ok - ng) > 1) {
    long long mid = (ok + ng) / 2;
    if (check(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  return ok;
}
int perm(int n, int r) {
  if (r == 1) return n;
  return n * perm(n - 1, r - 1);
}
int fact(int n) {
  if (n == 1) return 1;
  return fact(n - 1) * n;
}
int comb(int n, int r) {
  int a = min(n, r), b = max(n, r);
  return perm(a, b) / fact(a);
}
long long inv_mod(long long a, long long mod) {
  long long b = mod, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0) u += mod;
  return u;
}
long long fact_mod(long long n, long long mod) {
  long long f = 1;
  for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
  return f;
}
long long pow_mod(long long x, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
long long comb_mod(long long n, long long r, long long mod) {
  if (r > n - r) r = n - r;
  if (r == 0) return 1;
  long long a = 1;
  for (int i = 0; i < r; i++) a = a * ((n - i) % mod) % mod;
  long long b = pow_mod(fact_mod(r, mod), mod - 2, mod);
  return (a % mod) * (b % mod) % mod;
}
int N, M;
vector<vector<int>> light;
vector<int> p;
bool flag(int bit) {
  bool res = true;
  for (int i = 0; i < M; i++) {
    int sum = 0;
    for (int j = 0; j < N; j++) {
      if (bit & (1 << j)) sum++;
    }
    if (sum % 2 != p[i]) res = false;
  }
  return res;
}
int solve() {
  int res = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    if (flag(bit)) res++;
  }
  return res;
}
int main() {
  cin >> N >> M;
  light.resize(M);
  p.resize(M);
  for (int i = 0; i < (M); ++i) {
    int k;
    cin >> k;
    light[i].resize(k);
    for (int j = 0; j < (k); ++j) {
      int s;
      cin >> s;
      s--;
      light[i][j] = s;
    }
  }
  for (int i = 0; i < (M); ++i) cin >> p[i];
  cout << solve() << endl;
  return 0;
}
