#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 3;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
const int inf = 1e9;
int n, m, a[N], k, q, u, v, x, y, tc, c, l, r, ans, sz[N], b[N];
char s[N];
vector<int> g[10];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &x);
    while (x--) {
      scanf("%d", &y);
      g[i].push_back(--y);
    }
  }
  for (int i = 0; i < m; i++) scanf("%d", &b[i]);
  for (int msk = 1; msk < (1 << n); msk++) {
    bool ok = true;
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (auto j : g[i]) {
        if ((msk & (1 << j))) {
          cnt++;
        }
      }
      if ((cnt % 2) != b[i]) ok = false;
    }
    if (ok) ans++;
  }
  printf("%d", ans);
}
