#include <bits/stdc++.h>
using namespace std;
long long INF = 1e16 + 7;
long long mod = 1e9 + 7;
long long dx[4] = {1, 0, -1, 0};
long long dy[4] = {0, 1, 0, -1};
signed main() {
  long long N, M;
  cin >> N >> M;
  vector<vector<long long>> s(M);
  vector<long long> p(M);
  for (long long i = 0; i < M; i++) {
    long long k;
    cin >> k;
    for (long long j = 0; j < k; j++) {
      long long X;
      cin >> X;
      X--;
      s[i].push_back(X);
    }
  }
  for (long long i = 0; i < M; i++) {
    cin >> p[i];
  }
  long long ans = 0;
  for (long long bit = 0; bit < (1 << N); bit++) {
    bool ok = true;
    for (long long i = 0; i < M; i++) {
      long long cnt = 0;
      for (long long j = 0; j < s[i].size(); j++) {
        if (1 & (bit >> j)) {
          cnt++;
        }
      }
      if (cnt % 2 != p[i]) {
        ok = false;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
}
