#include <bits/stdc++.h>
using namespace std;
int s[10];
int two(int N) {
  int a = 1;
  while (N > 0) {
    a *= 2;
    N--;
  }
  return a;
}
void sw(int N, int s[]) {
  int x = N;
  for (int i = 0; i < N; i++) {
    s[i] = x % 2;
    x = x / 2;
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  int k1[M], k[M][N];
  for (int i = 0; i < M; i++) {
    cin >> k1[i];
    for (int l = 0; l < k1[i]; l++) {
      cin >> k[i][l];
    }
  }
  int p[M];
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int pattern = two(N);
  int ans = 0;
  int Answer = 0;
  for (int t = 0; t < pattern; t++) {
    sw(t, s);
    for (int i = 0; i < M; i++) {
      int P = 0;
      for (int l = 0; l < k1[i]; l++) {
        if (s[k[i][l]] == 1) {
          P++;
        }
      }
      if (P % 2 == p[i]) {
        ans++;
      }
    }
    if (ans == M) {
      Answer++;
    }
    ans = 0;
  }
  cout << Answer << endl;
  return 0;
}
