#include <bits/stdc++.h>
using namespace std;
long long N, M;
long long K[10];
long long S[10][10];
long long P[10];
signed main() {
  cin >> N >> M;
  for (long long i = 0; i < M; i++) {
    cin >> K[i];
    for (long long j = 0; j < K[i]; j++) cin >> S[i][j];
  }
  for (long long i = 0; i < M; i++) cin >> P[i];
  long long ans = 0;
  for (long long i = 0; i < (1 << N); i++) {
    long long cnt = 0;
    for (long long j = 0; j < M; j++) {
      long long tmp = 0;
      for (long long k = 0; k < K[i]; k++) {
        if (i & (1 << (S[i][j] - 1))) tmp++;
      }
      if (tmp % 2 == P[i]) cnt++;
    }
    if (cnt == N) ans++;
  }
  cout << ans << endl;
  return 0;
}
