#include <bits/stdc++.h>
using namespace std;
template <typename T>
T pow(T k, T n) {
  T x = 1;
  while (n > 0) {
    if (n & 1) {
      x *= k;
    }
    k *= k;
    n >>= 1;
  }
  return x;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  set<int> se;
  vector<int> k(M), p(M);
  vector<vector<int> > s(M, vector<int>(N));
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int on = 0; on < 1 << N; on++) {
    int cnt = 0;
    bool b = true;
    for (int j = 0; j < M; j++) {
      for (int i = 0; i < k[j]; i++) {
        if (on & (1 << s[j][i])) cnt++;
      }
      if (cnt % 2 != p[j]) b = false;
    }
    if (b) ans++;
  }
  cout << ans << endl;
  getchar();
  getchar();
}
