#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s(N);
  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 bits = 0; bits < (1 << N); bits++) {
    vector<bool> s_on(N, false);
    bool ok = true;
    for (int i = 0; i < N; i++) {
      if ((bits >> i) & 1) {
        s_on[i] = true;
      }
    }
    for (int i = 0; i < M; i++) {
      int sum = 0;
      for (int j = 0; j < k[i]; j++) {
        if (s_on[s[i][j] - 1]) sum++;
      }
      if (sum % 2 != p[i]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
