#include <bits/stdc++.h>
using namespace std;
long long d1[4] = {1, -1, 0, 0};
long long d2[4] = {0, 0, 1, -1};
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> k(M);
  vector<vector<long long>> s(M, vector<long long>(N));
  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 << i) {
        sw[i] = true;
      }
    }
    long long c = 0;
    for (long long i = (0); i < (long long)(M); i++) {
      long long tc = 0;
      for (long long j = (0); j < (long long)(k[i]); j++) {
        if (sw[j]) tc++;
      }
      if (tc % 2 == p[i]) c++;
    }
    if (c == M) ans++;
  }
  cout << ans << endl;
  return 0;
}
