#include <bits/stdc++.h>
int n, m, ans, k[13][12], p[12];
int mj(int x) {
  int a[12], i, j, s;
  bool f = 0;
  for (i = m; i >= 1; i--) {
    a[i] = x % 2;
    x /= 2;
  }
  for (i = 1; i <= m; i++) {
    s = 0;
    for (j = 1; j <= k[i][0]; j++) {
      s += a[k[i][j]];
    }
    s %= 2;
    if (s != p[i]) {
      f = 1;
      break;
    }
  }
  if (f == 1)
    return 0;
  else {
    return 1;
  }
}
int main() {
  int i, j, u;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d", &k[i][0]);
    for (j = 1; j <= k[i][0]; j++) {
      scanf("%d", &k[i][j]);
    }
  }
  for (i = 1; i <= m; i++) {
    scanf("%d", &p[i]);
  }
  ans = 0;
  u = 1;
  for (i = 1; i <= m; i++) u *= 2;
  u--;
  for (i = 0; i <= u; i++) {
    if (mj(i)) {
      ans++;
    }
  }
  printf("%d\n", ans);
}
