#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long N, M, k, x;
  cin >> N >> M;
  vector<long long> p(M);
  vector<vector<long long> > s(M, vector<long long>(N));
  for (long long i = 0; i < (M); i++) {
    cin >> k;
    for (long long _ = 0; _ < (k); _++) {
      cin >> x;
      s[i][x]++;
    }
  }
  for (long long i = 0; i < (M); i++) cin >> p[i];
  long long B = (long long)pow(2, N), ans = 0;
  for (long long sub = 0; sub < (B); sub++) {
    bool all_on = true;
    for (long long i = 0; i < (M); i++) {
      long long onSWITCH = 0;
      for (long long j = 0; j < (N); j++) {
        if ((((sub) >> (j)) & 1) and s[i][j]) onSWITCH++;
      }
      if (onSWITCH % 2 != p[i]) all_on = false;
    }
    if (all_on) ans++;
  }
  cout << ans << "\n";
}
