#include <bits/stdc++.h>
int main(void) {
  int i, j, max = 1, ans, sign, sum, a;
  int n, m;
  scanf("%d%d", &n, &m);
  int s[m + 1][n + 1];
  int k[m + 1];
  for (i = 1; i <= m; i++) {
    scanf("%d", &k[i]);
    for (j = 1; j <= k[i]; j++) {
      scanf("%d", &s[i][j]);
    }
  }
  int ss[m + 1][n + 1];
  for (i = 0; i <= m; i++) {
    for (j = 0; j <= n; j++) {
      ss[i][j] = 0;
    }
  }
  for (i = 1; i <= m; i++) {
    for (j = 1; j <= k[i]; j++) {
      ss[i][s[i][j]] = 1;
    }
  }
  int p[m + 1];
  for (i = 1; i <= m; i++) {
    scanf("%d", p[i]);
  }
  for (i = 0; i < n; i++) {
    max *= 2;
  }
  int t[n + 1];
  for (a = 0; a < max; a++) {
    for (i = 1; i <= n; i++) {
      t[i] = a % 2;
      a /= 2;
    }
    sign = 0;
    sum = 0;
    for (i = 1; i <= m; i++) {
      for (j = 1; j <= n; j++) {
        sum += ss[i][j] * t[j];
      }
      if (sum % 2 != p[i]) {
        sign = 1;
        break;
      }
    }
    if (sign == 0) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
