#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
int main(int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  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 tmp;
      cin >> tmp;
      tmp--;
      s[i].push_back(tmp);
    }
  }
  vector<ll> 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 cnt = 0;
      for (ll j = 0; j < (s[i].size()); j++) {
        if (bit & (1 << j)) {
          cnt++;
        }
      }
      if (cnt % 2 != p[i]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
