#include <bits/stdc++.h>
using namespace std;
int n, m, tmp[12], ans, s[12][12], p[12];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, x, k; i <= m; i++) {
    scanf("%d", &k);
    for (int j = 1; j <= k; j++) scanf("%d", &x), s[x][++s[x][0]] = i;
  }
  for (int i = 1; i <= m; i++) scanf("%d", &p[i]);
  for (int i = 0; i < (1 << n); i++) {
    memset(tmp, 0, sizeof tmp);
    for (int j = 0; j < n; j++)
      if ((i & (1 << j)) == (1 << j)) {
        printf("ww1");
        for (int q = 1; q <= s[j + 1][0]; q++) tmp[s[j + 1][q]]++;
      }
    int f = 1;
    for (int j = 1; j <= m; j++)
      if ((p[j] % 2) != (tmp[j] % 2)) f = 0;
    ans += f;
  }
  printf("%d", ans);
}
