#include <bits/stdc++.h>
int n, m, k[10], s[10][10], p[10];
int check(int state) {
  int b[10], on[10], i, j;
  for (i = 0; i < m; i++) on[i] = !p[i];
  for (i = 0; i < n; i++) {
    if (state & (1 << i))
      for (j = 0; j < k[i]; j++) on[s[i][j]] = !on[s[i][j]];
  }
  for (i = 0; i < m; i++)
    if (!on[i]) break;
  return i == m;
}
int main() {
  int c = 0, i, j;
  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d", &k[i]);
    for (j = 0; j < k[i]; j++) {
      scanf("%d", &s[i][j]);
      s[i][j]--;
    }
  }
  for (i = 0; i < m; i++) scanf("%d", &p[i]);
  for (i = 0; i < (1 << n); i++) c += check(i);
  printf("%d", c);
  return 0;
}
