// ------------------
// author: MatsuTaku
// date  : 22/02/2020
// ------------------

#include <bits/stdc++.h>
#include <x86intrin.h>

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);

  int N,M; cin>>N>>M;
  vector<unsigned int> l_mask(M, 0);
  for (int i = 0; i < M; i++) {
    int k; cin>>k;
    for (int j = 0; j < k; j++) {
      int s; cin>>s;
      l_mask[i] |= 1<<(s-1);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin>>p[i];
  }

  int ans = 0;
  for (int s = 0; s < (1<<N); s++) {
    bool ok = true;
    for (int i = 0; i < M; i++) {
      if (_mm_popcnt_u32((unsigned int)s&l_mask[i])%2 != p[i]) {
        ok = false;
        break;
      }
    }
    if (ok)
      ans++;
  }
  cout << ans << endl;

  return 0;
}
