#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, M;
  cin >> N >> M;
  vector<vector<long long>> s(M);
  for (long long i = 0, i_len = (M); i < i_len; ++i) {
    long long k;
    cin >> k;
    for (long long j = 0, j_len = (k); j < j_len; ++j) {
      long long t;
      cin >> t;
      t--;
      s[i].push_back(t);
    }
  }
  vector<long long> p(M);
  for (long long i = 0, i_len = (M); i < i_len; ++i) cin >> p[i];
  long long ans = 0;
  for (long long bit = 0, bit_len = (1 << N); bit < bit_len; ++bit) {
    bool ok = true;
    for (long long sw = 0; sw < M; sw++) {
      long long c = 0;
      for (long long i = 0; i < s[sw].size(); i++) {
        if (bit & (1 << i)) c++;
      }
      if (c % 2 != p[sw]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
