#include <bits/stdc++.h>
using namespace std;
map<long long, vector<long long> > mp;
void solve() {
  long long n, m;
  scanf("%lld %lld", &n, &m);
  for (int i = 0; i < m; i++) {
    long long k;
    scanf("%lld", &k);
    for (int j = 0; j < k; j++) {
      long long s;
      scanf("%lld", &s);
      mp[s - 1].push_back(j);
    }
  }
  vector<long long> p(m);
  for (int i = 0; i < m; i++) scanf("%lld", &p[i]);
  long long pset = pow(2, n);
  long long ct = 0;
  for (int i = 0; i < pset; i++) {
    vector<long long> b(m, 0);
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        vector<long long> tmp = mp[j];
        for (int x = 0; x < (int)tmp.size(); x++) {
          b[tmp[x]]++;
        }
      }
    }
    long long flag = 1;
    for (int j = 0; j < m; j++) {
      if (p[j] != (b[j] % 2)) flag = 0;
    }
    if (flag) ct++;
  }
  printf("%lld", ct);
  printf("\n");
  return;
}
int main() {
  solve();
  return 0;
}
