#include <bits/stdc++.h>
int main() {
  int n, m, a, b, c, i, j, k, p[10], d[20][20] = {};
  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d", &b);
    for (j = 0; j < b; j++) {
      scanf("%d", &a);
      d[i][a - 1] = 1;
    }
  }
  for (i = 0; i < m; i++) scanf("%d", &p[i]);
  for (i = b = 0; i < (1 << n); i++) {
    for (k = a = 0; k < m; k++) {
      for (j = c = 0; j < n; j++) {
        if (d[j][k] == 0) continue;
        if (i & (1 << j)) c++;
      }
      if (c % 2 == p[k]) a++;
    }
    if (a == m) b++;
  }
  printf("%d\n", b);
  return 0;
}
