#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(N);
  vector<vector<int> > s(M);
  for (long long i = 0; i < M; i++) {
    cin >> k[i];
    for (long long j = 0; j < k[i]; j++) {
      int x;
      cin >> x;
      s[i].push_back(x);
    }
  }
  vector<int> p(M);
  for (long long i = 0; i < M; i++) cin >> p[i];
  int ans = 0;
  for (long long i = 0; i < 1 << N; i++) {
    vector<int> v;
    for (long long j = 0; j < N; j++) {
      if ((i >> j) & 1) v.push_back(j);
    }
    bool f = true;
    for (long long kk = 0; kk < M; kk++) {
      int fl = 0;
      for (long long l = 0; l < k[kk]; l++) {
        for (long long m = 0; m < v.size(); m++) {
          if (s[kk][l] == v[m]) fl += 1;
        }
      }
      if (fl % 2 != p[kk]) f = false;
    }
    if (f) ans += 1;
  }
  cout << ans << endl;
  return 0;
}
