#include <bits/stdc++.h>
int upcmpll(const void *a, const void *b) {
  return (*(long long *)a == *(long long *)b
              ? 0
              : (*(long long *)a > *(long long *)b ? 1 : -1));
}
void sort_u(long long *a, int n) { qsort(a, n, sizeof(long long), upcmpll); }
int k[12], s[12][12], p[12];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (int)(m); i++) {
    scanf("%d", k + i);
    for (int j = 0; j < (int)(k[i]); j++) {
      scanf("%d", &s[i][j]);
    }
  }
  for (int i = 0; i < (int)(m); i++) scanf("%d", p + i);
  int ans = 0;
  for (int bit = 0; bit < (int)((1 << n)); bit++) {
    int t_lmp = 0;
    for (int i = 0; i < (int)(m); i++) {
      int tmp_sum = 0;
      for (int j = 0; j < (int)(k[i]); j++) {
        if (bit & (1 << j)) tmp_sum++;
      }
      if (tmp_sum % 2 == p[i])
        t_lmp++;
      else
        break;
    }
    if (t_lmp == m) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
