#include <bits/stdc++.h>
using namespace std;
const long long N = 300005;
int ce(int a, int b) { return (a + b - 1) / b; }
int n, m, k, x;
int p[11], t[11];
vector<int> gr[11];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d", &k);
    for (int j = 0; j < k; ++j) {
      scanf("%d", &x);
      gr[j].push_back(x);
    }
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d", &p[i]);
  }
  int mask = 0, ans = 0;
  int yo = pow(2, n);
  while (mask < yo) {
    int aux = mask;
    for (int i = 1; i <= n; ++i) {
      t[i] = aux % 2;
      aux /= 2;
    }
    int r = 0;
    for (int i = 0; i < m; ++i) {
      int s = 0;
      for (int l : gr[i]) {
        if (t[l]) s++;
      }
      if (s % 2 == p[i]) r++;
    }
    if (r == m) {
      ans++;
    }
    memset(t, 0, sizeof t);
    mask++;
  }
  printf("%d\n", ans);
  return 0;
}
