#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("tune=native")
#pragma GCC target("avx")
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
T gcd(const T &a, const T &b) {
  return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(const T &a, const T &b) {
  return a / gcd(a, b) * b;
}
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using namespace std;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> s(m);
  for (long long i = 0, i_len = (m); i < i_len; i++) {
    ll k;
    cin >> k;
    s[i].resize(k);
    for (long long j = 0, j_len = (k); j < j_len; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  vector<ll> p(m);
  for (long long i = 0, i_len = (m); i < i_len; i++) cin >> p[i];
  ll ans = 0;
  for (long long mask = 0, mask_len = (1LL << n); mask < mask_len; mask++) {
    vector<ll> sn = p;
    for (long long i = 0, i_len = (m); i < i_len; i++) {
      if (mask & (1LL << i)) {
        sn[i] ^= 1;
      }
    }
    bool okay = true;
    for (auto &s : sn) {
      if (s) {
        okay = false;
        break;
      }
    }
    if (okay) ans++;
  }
  cout << ans << endl;
}
