#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (const auto i : v) {
    os << i << " ";
  }
  os << "]";
  return os;
}
int main(int argc, char const* argv[]) {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s(M);
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    s[i].resize(k[i]);
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int state = 0; state < (1 << N); state++) {
    vector<bool> switch_on(N);
    for (int j = 0; j < N; j++) {
      switch_on[j] = (state >> j) & 1;
    }
    bool all_on = true;
    for (int i = 0; i < M; i++) {
      int count = 0;
      for (int j = 0; j < k[i]; j++) {
        count += switch_on[j];
      }
      if (count % 2 != p[i]) {
        all_on = false;
        break;
      }
    }
    if (all_on) {
      ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}
