#include <bits/stdc++.h>
using namespace std;
int n, m;
int k[100];
int s[100][100];
int p[100];
int a[100];
int ans;
int check() {
  for (int i = 1; i <= m; i++) {
    int cnt;
    for (int j = 1; j <= k[i]; j++) {
      cnt += a[s[i][j]];
    }
    if (cnt % 2 != p[i]) {
      return 0;
    }
  }
  return 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &k[i]);
    for (int j = 1; j <= k[i]; j++) {
      scanf("%d", &s[i][j]);
    }
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &p[i]);
  }
  for (int i = 0; i < pow(2, n); i++) {
    for (int j = 1; j <= m; j++) {
      a[j] = (i >> j - 1) & 1;
    }
    ans += check();
  }
  printf("%d\n", ans);
  return 0;
}
