#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
int main() {
  ll N, M;
  cin >> N >> M;
  vector<vector<ll>> s(M);
  for (ll i = 0; i < M; i++) {
    ll k;
    cin >> k;
    for (ll j = 0; j < k; j++) {
      ll a;
      cin >> a;
      s[i].push_back(a);
    }
  }
  vll p(M);
  for (ll i = 0; i < M; i++) cin >> p[i];
  ll ans = 0;
  for (ll bit = 0; bit < (1 << N); bit++) {
    bool ok = true;
    for (ll i = 0; i < M; i++) {
      ll con = 0;
      for (auto v : s[i]) {
        if (bit & (1 << v)) ++con;
      }
      if (con % 2 != p[i]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
