#include <bits/stdc++.h>
using namespace std;
constexpr double pi = M_PI;
signed main(signed argc, char* argv[]) {
  long long N, M;
  cin >> N >> M;
  long long k[20];
  long long s[20];
  for (long long i = 0; i < M; i++) {
    cin >> k[i];
    s[i] = 0;
    for (long long j = 0; j < k[i]; j++) {
      long long sij;
      cin >> sij;
      s[i] |= (1 << sij - 1);
    }
  }
  long long p[20];
  for (long long i = 0; i < M; i++) {
    cin >> p[i];
  }
  long long ans = 0;
  for (long long bits = 0; bits < (1 << N); bits++) {
    bool ok = true;
    for (long long i = 0; i < M; i++) {
      ok &= (__builtin_popcount(bits & s[i]) % 2 == p[i]);
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
}
