#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> k(M);
  vector<vector<long long>> s(M, vector<long long>(N, 0));
  for (long long i = (0); i < (long long)(M); i++) {
    cin >> k[i];
    for (long long j = (0); j < (long long)(k[i]); j++) {
      cin >> s[i][j];
    }
  }
  vector<long long> p(M);
  for (long long i = (0); i < (long long)(M); i++) cin >> p[i];
  long long ans = 0;
  for (long long bit = (0); bit < (long long)(1LL << N); bit++) {
    vector<bool> sw(N, false);
    for (long long i = (0); i < (long long)(N); i++) {
      if (bit & 1LL << N) sw[i] = true;
    }
    long long c = 0;
    for (long long i = (0); i < (long long)(M); i++) {
      long long ctmp = 0;
      for (long long j = (0); j < (long long)(k[i]); j++) {
        if (sw[s[i][j]]) ctmp++;
      }
      if (ctmp % 2 == p[i]) c++;
    }
    if (c == M) ans++;
  }
  cout << ans << endl;
  return 0;
}
