#include <bits/stdc++.h>
using namespace std;
template <class T>
T inf() {
  return numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity()
                                         : (numeric_limits<T>::max() / 2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N, M;
  cin >> N >> M;
  vector<uint> v(N);
  for (int i = 0; i < (int)(M); ++i) {
    int k;
    cin >> k;
    for (int i = 0; i < (int)(k); ++i) {
      int s;
      cin >> s;
      s--;
      v[s] ^= (1 << i);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < (int)(M); ++i) cin >> p[i];
  int ans = 0;
  const uint B = (1u << N);
  for (int b = 0; b < (int)(B); ++b) {
    uint t = 0;
    for (int i = 0; i < (int)(N); ++i) {
      if ((1u << i) & b) {
        t ^= v[i];
      }
    }
    int sum = 0;
    for (int i = 0; i < (int)(M); ++i) {
      if (t & (1u << i)) {
        if (p[i]) sum++;
      } else {
        if (!p[i]) sum++;
      }
    }
    if (sum == M) ans++;
  }
  cout << ans << endl;
  return 0;
}
