#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
ll gcd(ll x, ll y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
const int mod = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  int k[10], s[10][10], p[10];
  for (int i = 0; (i) < (m); ++(i)) {
    cin >> k[i];
    for (int j = 0; (j) < (k[i]); ++(j)) cin >> s[i][j];
  }
  for (int i = 0; (i) < (m); ++(i)) cin >> p[i];
  int ans = 0;
  for (int b = 0; (b) < (1 << n); ++(b)) {
    int light = 0;
    for (int i = 0; (i) < (m); ++(i)) {
      int sw_on = 0;
      for (int j = 0; (j) < (k[i]); ++(j))
        if (1 << s[i][j] & b) sw_on++;
      if (sw_on % 2 == p[i]) light++;
    }
    if (light == m) ans++;
  }
  cout << ans;
  return 0;
}
