#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<int> s(M);
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    s[i] = 0;
    for (int j = 0; j < k[i]; j++) {
      int sij;
      cin >> sij;
      s[i] |= (1 << (sij - 1));
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  vector<int> on(1 << N, 0);
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < (1 << N); j++) {
      if (__builtin_popcount(j & s[i]) % 2 == p[i]) {
        on[j]++;
      }
    }
  }
  int count = 0;
  for (int i = 0; i < (1 << N); i++) {
    if (on[i] == M) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
