#include <bits/stdc++.h>
int main(void) {
  int n, m;
  int k[10];
  int s[10][10];
  int sw[10] = {0};
  int p[10];
  int sum = 1;
  int count = 0;
  int i, j, l, o;
  int work;
  int sum_sw;
  int flg;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d", &k[i]);
    for (j = 0; j < k[i]; j++) {
      scanf("%d", &s[i][j]);
    }
  }
  for (i = 0; i < m; i++) {
    scanf("%d", &p[i]);
  }
  for (i = 0; i < n; i++) {
    sum *= 2;
  }
  for (i = 0; i <= sum; i++) {
    work = i;
    for (j = 0; j < 10; j++) {
      sw[j] = 0;
    }
    for (j = 0; work > 0; j++) {
      if ((work % 2) == 1) {
        sw[j] = 1;
      } else {
        sw[j] = 0;
      }
      work /= 2;
    }
    flg = 0;
    for (l = 0; l < m; l++) {
      sum_sw = 0;
      for (o = 0; o < k[l]; o++) {
        sum_sw += sw[s[l][o] - 1];
      }
      if (sum_sw % 2 != p[l]) {
        flg = 1;
        break;
      }
    }
    if (flg) {
      continue;
    }
    count++;
  }
  printf("%d\n", count);
  return 0;
}
