#include <bits/stdc++.h>
using namespace std;
const long long LLINF = (1LL << 60);
const int INF = (1LL << 30);
const int MOD = 1000000007;
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;
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> K(M), P(M);
  vector<vector<int>> S(M);
  for (int i = 0; i < M; i++) {
    cin >> K[i];
    for (int j = 0; j < K[i]; j++) {
      int s;
      cin >> s;
      S[j].push_back(s);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> P[i];
  }
  int res = 0;
  for (int bit = 0; bit < 1 << N; bit++) {
    bool ok = true;
    for (int i = 0; i < N; i++) {
      int count = 0;
      for (auto v : S[i]) {
        if (bit & (1 << v)) count++;
      }
      if (count % 2 != P[i]) ok = false;
    }
    if (ok) ++res;
  }
  cout << res << endl;
}
