#include <bits/stdc++.h>
int N, M;
int k[11];
int s[11][11];
int p[11];
int judge(int bit) {
  int cnt;
  for (int i = 1; i <= N; i++) {
    cnt = 0;
    for (int j = 1; j <= k[i]; j++) {
      if (bit & (1 << (s[i][j] - 1))) cnt++;
    }
    if ((cnt % 2) != p[i]) return 0;
  }
  return 1;
}
int main() {
  int total = 0;
  scanf("%d %d", &N, &M);
  for (int i = 1; i <= M; i++) {
    scanf("%d", &k[i]);
    for (int j = 1; j <= k[i]; j++) {
      scanf("%d", &s[i][j]);
    }
  }
  for (int i = 1; i <= M; i++) scanf("%d", &p[i]);
  for (int bit = 0; bit < (1 << N); bit++) {
    if (judge(bit)) total++;
  }
  printf("%d", total);
}
