#include <bits/stdc++.h>
using namespace std;
int n, m;
int bm[12];
int init = 0;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int mask = 0;
    int k, x;
    scanf("%d", &k);
    while (k--) {
      scanf("%d", &x);
      x--;
      mask |= (1 << x);
    }
    bm[i] = mask;
  }
  int mask = 0;
  for (int i = 0; i < m; i++) {
    int p;
    scanf("%d", &p);
    if (p == 1) mask ^= bm[i];
  }
  int ans = 0, mask2 = 0;
  for (int i = 0; i < (1 << m); i++) {
    mask2 = mask;
    for (int j = 0; j < m; j++) {
      if ((i >> j) & 1) mask2 ^= bm[j];
    }
    if (mask2 == (1 << m) - 1) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
