#include <bits/stdc++.h>
using namespace std;
template <typename T>
void DEBUG(T e) {
  if (true == false) return;
  std::cout << e << " ";
}
template <typename T>
void DEBUG(const std::vector<T>& v) {
  if (true == false) return;
  for (const auto& e : v) {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void DEBUG(const std::vector<std::vector<T> >& vv) {
  if (true == false) return;
  for (const auto& v : vv) {
    DEBUG(v);
  }
}
template <class T, class... Ts>
void DEBUG(T d, Ts... e) {
  if (true == false) return;
  DEBUG(d);
  DEBUG(e...);
}
template <class T>
void corner(bool flg, T hoge) {
  if (flg) {
    cout << hoge << endl;
    abort();
  }
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b) {
  return a < b && (a = b, true);
}
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b) {
  return a > b && (a = b, true);
}
void solve(void) {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long> > v_switch(n, vector<long long>(m, 0));
  for (long long i = 0; i < m; i++) {
    long long k;
    cin >> k;
    for (long long j = 0; j < k; j++) {
      long long x;
      cin >> x;
      v_switch[k - 1][i] = 1;
    }
  }
  vector<long long> data(m, 0);
  for (long long i = 0; i < m; i++) {
    cin >> data[i];
  }
  long long res = 0;
  for (long long b = 0; b < (1 << n); b++) {
    vector<long long> bit;
    for (long long i = 0; i < n; i++) {
      bit.push_back((b >> i) & 1);
    }
    vector<long long> on(m, 0);
    for (long long i = 0; i < n; i++) {
      if (bit[i] == 0) continue;
      for (long long j = 0; j < m; j++) {
        on[j] += v_switch[i][j];
      }
    }
    long long flg = 1;
    for (long long i = 0; i < m; i++) {
      if (data[i] != on[i] % 2) flg = 0;
    }
    if (flg) res++;
  }
  cout << res << endl;
  return;
}
int32_t main(int32_t argc, const char* argv[]) {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();
  return 0;
}
