#include <bits/stdc++.h>
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int k[m], s[m][n];
  for (int i = 0; i < n; ++i) {
    scanf("\n%d", &k[i]);
    for (int j = 0; j < k[i]; ++j) {
      scanf("%d", &s[i][j]);
    }
  }
  scanf("\n");
  int p[m];
  for (int i = 0; i < m; ++i) scanf("%d", &p[i]);
  int swi[n];
  int pow[11] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
  int count, answer = 0, flag;
  for (int i = 0; i < pow[n]; ++i) {
    flag = 0;
    for (int j = 0; j < n; ++j) {
      swi[j] = (i / pow[j]) % 2;
    }
    for (int j = 0; j < m; ++j) {
      count = 0;
      for (int l = 0; l < k[j]; ++l) {
        if (swi[s[j][l] - 1] == 1) count++;
      }
      if ((count % 2) != p[j]) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) answer++;
  }
  printf("%d", answer);
  return 0;
}
