#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9 + 7;
const ll inf = 1e15;
ll m, n;
ll s[11][11];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  vll k(m);
  vll p(m);
  for (long long i = 0; i < m; i++) {
    cin >> k[i];
    for (long long j = 0; j < k[i]; j++) {
      ll S;
      cin >> S;
      s[i][S - 1] = 1;
    }
  }
  for (long long i = 0; i < m; i++) cin >> p[i];
  ll ans = 0;
  for (ll i = 0; i < (1 << n); i++) {
    bool all = true;
    vll q(m, 0);
    for (long long j = 0; j < m; j++) {
      ll cnt = 0;
      for (long long k = 0; k < n; k++) {
        if (s[j][k] && (i >> j & 1)) cnt++;
      }
      if (cnt % 2 != p[j]) all = false;
    }
    if (all) ans++;
  }
  cout << ans / 2 << endl;
  return 0;
}
