#include <bits/stdc++.h>
int main(int argc, char *argv[]) {
  int n, m, k[10], s[10][10], p[10];
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &k[i]);
    for (int j = 0; j < k[i]; j++) scanf("%d", &s[i][j]);
  }
  for (int i = 0; i < m; i++) scanf("%d", &p[i]);
  int sw[1024][10];
  int d, r, l;
  int w = 1;
  for (int i = 0; i < n; i++) {
    w *= 2;
  }
  for (int j = 0; j < w; j++) {
    d = 2;
    r = j;
    l = 0;
    while (r > 0) {
      sw[j][l++] = r % 2;
      r /= 2;
    }
  }
  int sum;
  int flag;
  int ans = 0;
  for (int i = 1; i < w; i++) {
    flag = 0;
    for (int j = 0; j < m; j++) {
      sum = 0;
      for (int q = 0; q < k[j]; q++) {
        sum += sw[i][s[j][q] - 1];
      }
      if (sum % 2 == p[j])
        flag++;
      else
        break;
    }
    if (flag == m) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
