#include <bits/stdc++.h>
using namespace std;
int bub[12][12];
int p[12];
int on[12];
signed main() {
  int n, m, k, s;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &k);
    for (int j = 1; j <= k; j++) {
      scanf("%d", &s);
      bub[i][s] = 1;
    }
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &p[i]);
  }
  int ans = 0;
  for (int i = 0; i < (1 << n) - 1; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= m; k++) {
        if (i & (j - 1)) {
          if (bub[k][j]) on[k]++;
        }
      }
    }
    for (int j = 1; j <= m; j++) {
      if ((on[j] % 2) != p[j]) {
        goto L;
      }
    }
    ans++;
  L:;
    for (int j = 0; j <= 10; j++) {
      on[j] = 0;
    }
  }
  printf("%d", ans);
  return 0;
}
