#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
int main(void) {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> vec(M);
  for (int i = 0; i < M; ++i) {
    int k;
    cin >> k;
    vec[i].resize(k);
    for (int j = 0; j < k; ++j) {
      cin >> vec[i][j];
      vec[i][j]--;
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; ++i) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 << N); ++i) {
    bool ok = true;
    for (int j = 0; j < M; ++j) {
      int c = 0;
      for (int id : vec[j])
        if ((i >> id) & 1) c++;
      if (c % 2 != p[j]) ok = false;
    }
    if (ok) ans++;
  }
  return 0;
}
