#include <bits/stdc++.h>
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int k[m], swi[m][15], pos[m];
  for (int i = 0; i < m; i++) {
    scanf("%d", &k[i]);
    int j = 0;
    for (; j < k[i]; j++) {
      scanf("%d", &swi[i][j]);
    }
    swi[i][j] = -1;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &pos[i]);
  }
  int swip = 0;
  int sp[n];
  int count = 0, max = pow(2, n);
  int temp1, temp2, temp3, temp4;
  while (swip <= max) {
    temp4 = swip;
    for (int i = 0; i < n; i++) {
      sp[i] = temp4 % 2;
      temp4 = temp4 / 2;
    }
    temp1 = 0;
    for (int i = 0; i < m; i++) {
      temp2 = 0;
      temp3 = 0;
      for (int j = 0; j < k[i]; j++) {
        if (sp[swi[i][j] - 1] == 1) {
          temp2++;
        }
      }
      if (temp2 % 2 == pos[i]) temp1++;
    }
    if (temp1 == m) count++;
    swip++;
  }
  printf("%d\n", count);
  return 0;
}
