#include <bits/stdc++.h>
int count(unsigned x, unsigned mask) {
  int count = 0, z = x & mask;
  while (z > 0) {
    if ((z & 01) == 01) {
      count += 1;
    }
    z >>= 1;
  }
  return count % 2;
}
int main(void) {
  int mask[10], p[10], i, j, x, M, N, T;
  scanf("%d%d", &N, &M);
  for (i = 0; i < M; i++) {
    scanf("%d", &T);
    mask[i] = 0;
    for (j = 0; j < T; j++) {
      scanf("%d", &x);
      mask[i] = mask[i] | (1 << (x - 1));
    }
  }
  for (i = 0; i < M; i++) {
    scanf("%d", p + i);
  }
  int s = 0, wf = 1;
  for (i = 0; i <= (1 << (N)); i++) {
    wf = 1;
    for (j = 0; wf == 1 && j < M; j++) {
      if (count(i, mask[j]) != p[j]) wf = 0;
    }
    if (wf == 1) {
      s += 1;
    }
  }
  printf("%d\n", s);
  return 0;
}
