#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using Graph = vector<vector<long long>>;
signed main() {
  long long a, b;
  cin >> a >> b;
  vector<long long> c(b), e(b);
  long long d[20][20];
  for (long long i = 0; i < b; i++) {
    cin >> c[i];
    for (long long j = 0; j < c[i]; j++) cin >> d[i][j];
  }
  for (long long i = 0; i < b; i++) cin >> e[i];
  long long ans = 0;
  for (long long i = 0; i < (1 << a); i++) {
    bitset<10> bit(a);
    vector<bool> t(b, 0);
    for (long long j = 0; j < b; j++) {
      long long p = 0;
      for (long long k = 0; k < c[j]; k++) {
        if (bit[d[j][k] - 1]) p++;
      }
      if (p % 2 == e[j]) t[j] == 1;
    }
    bool cnt = 1;
    for (long long j = 0; j < b; j++) {
      if (!t[j]) cnt = 0;
    }
    if (cnt) ans++;
  }
  cout << ans << endl;
}
