#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1e9 + 7;
constexpr int INF = 1 << 30;
constexpr long long LINF = 1LL << 60;
template <typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}
template <typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}
void addmod(long long& a, long long b) { a = (a + b) % MOD; }
template <typename T>
void dumpContents(const T& v, const string& msg) {
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}
struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;
  }
} before_main_function;
long long pow_r(long long x, long long y) {
  assert(y >= 0);
  long long ret = 1;
  while (y > 0) {
    if (y % 2) {
      ret = ret * x;
    }
    x *= x;
    y >>= 1;
  }
  return ret;
}
vector<vector<int> > sets;
vector<int> ps;
int validate(const vector<int>& switches) {
  for (int i = 0; i < int(sets.size()); i++) {
    int x = 0;
    for (auto j : sets[i]) {
      x += switches[j];
    }
    if (x % 2 != ps[i]) {
      return 0;
    }
  }
  return 1;
}
int main(int argc, char** argv) {
  int N, M;
  cin >> N >> M;
  sets.resize(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    sets[i] = vector<int>(k);
    for (int j = 0; j < k; j++) {
      cin >> sets[i][j];
      sets[i][j]--;
    }
  }
  ps.resize(M);
  for (int i = 0; i < M; i++) {
    cin >> ps[i];
  }
  int ret = 0;
  for (uint32_t i = 0; i < pow_r(2, N); i++) {
    vector<int> switches(N);
    for (int j = 0; j < N; j++) {
      switches[j] = i >> j & 1u;
    }
    ret += validate(switches);
  }
  cout << ret << "\n";
  return 0;
}
