#include <bits/stdc++.h>
int main() {
  int bit, i, j, N, M, onoff, cont, acont = 0;
  int k[10], s[10][10], P[10];
  {
    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 (bit = 0; bit < pow(2.0, (double)N); bit++) {
      cont = 0;
      for (i = 0; i < M; i++) {
        for (j = 0; j < k[i]; j++) {
          onoff = (bit >> (s[i][j] - 1)) % 2;
          cont += onoff;
        }
        if (cont % 2 != P[i]) break;
      }
      if (i == M) acont++;
    }
  }
  printf("%d\n", acont);
  return 0;
}
