#include <bits/stdc++.h>
const int mod = 1000000000 + 7;
int main() {
  char buf[1024];
  int N, M;
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d %d", &N, &M);
  int **graph = (int **)malloc(sizeof(int *) * M);
  for (int i = 0; i < ((int)M); i++) {
    graph[i] = (int *)malloc(sizeof(int) * N);
  }
  for (int i = 0; i < ((int)M); i++) {
    for (int j = 0; j < ((int)N); j++) {
      graph[i][j] = 0;
    }
  }
  int *k = (int *)malloc(sizeof(int) * M);
  for (int i = 0; i < ((int)M); i++) {
    scanf("%d", &k[i]);
    for (int i = 0; i < ((int)k[i]); i++) {
      int temp;
      scanf("%d", &temp);
      graph[i][temp - 1]++;
    }
    int c = getchar();
  }
  int *p = (int *)malloc(sizeof(int) * M);
  for (int i = 0; i < ((int)M); i++) {
    scanf("%d", &p[i]);
  }
  int a_sum = 0;
  for (int i = 0; i < ((int)(1 << N) + 1); i++) {
    int sum = 0;
    for (int j = 0; j < ((int)M); j++) {
      int s_sum = 0;
      for (int k = 0; k < ((int)N); k++) {
        if ((i & (1 << k)) != 0 && graph[j][k] == 1) {
          s_sum++;
        }
      }
      if (s_sum % 2 == p[j]) {
        sum++;
      }
    }
    if (sum == M) {
      a_sum++;
    }
  }
  printf("%d\n", a_sum);
  return 0;
}
