#include <bits/stdc++.h>
int gcd(int a, int b);
int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  int k[10], s[10][10], p[10];
  int i, j;
  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]);
  int flag, q, ans = 0, miniflag;
  int light[10] = {0};
  for (i = 0; i < 1 << n; i++) {
    flag = 0;
    for (j = 0; j < m; j++) {
      miniflag = 0;
      for (q = 0; q < k[j]; q++) {
        if ((i >> (5 - s[j][q])) & 1) {
          miniflag++;
        }
      }
      if (miniflag % 2 == p[j])
        flag++;
      else
        break;
    }
    if (flag == m) {
      ans++;
    }
  }
  printf("%d", ans);
  return 0;
}
int gcd(int a, int b) {
  int max, min, tmp;
  max = ((a > b) ? (a) : (b));
  min = ((a < b) ? (a) : (b));
  if (max % min == 0)
    return min;
  else {
    tmp = min;
    min = max % min;
    max = tmp;
    return gcd(max, min);
  }
}
