#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, M;
  cin >> N >> M;
  vector<ll> switches(M);
  for (long long i = 0; i < (long long)(M); i++) {
    int L;
    cin >> L;
    ll b = 0;
    for (long long j = 0; j < (long long)(L); j++) {
      int s;
      cin >> s;
      b |= 1ll << (s - 1);
    }
    switches[i] = b;
  }
  vector<int> p(M);
  for (long long i = 0; i < (long long)(M); i++) {
    cin >> p[i];
  }
  ll ans = 0;
  for (ll i = 1; i < (1ll << N); i++) {
    int on_count = 0;
    for (long long j = 0; j < (long long)(M); j++) {
      ll bi = switches[j] & i;
      int count = 0;
      while (bi > 0) {
        if (bi & 1) {
          count++;
        }
        bi >>= 1;
      }
      if (count % 2 == p[j]) {
        on_count++;
      }
    }
    if (on_count == M) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
