#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
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;
}
signed main() {
  int n, m;
  cin >> n >> m;
  vvi vec(m, vi(0));
  for (int i = 0; i < (int)(m); i++) {
    int k;
    cin >> k;
    for (int j = 0; j < (int)(k); j++) {
      int s;
      cin >> s;
      vec[i].push_back(s);
    }
  }
  ll ans = 0;
  vi p(m);
  for (int i = 0; i < (int)(m); i++) cin >> p[i];
  for (int i = 0; i < (int)((1 << n)); i++) {
    bool ok = true;
    int cnt = 0;
    for (int j = 0; j < (int)(m); j++) {
      for (int c : vec[j]) {
        if (!(i >> (c - 1) & 1)) continue;
        ++cnt;
      }
      if (cnt % 2 != p[j]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans;
  return 0;
}
