#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> G[11];
  for (long long i = (0); i < (m); i++) {
    long long k;
    cin >> k;
    for (long long i = (0); i < (k); i++) {
      long long s;
      cin >> s;
      s--;
      G[i].push_back(s);
    }
  }
  vector<long long> p(m);
  for (long long i = (0); i < (m); i++) cin >> p[i];
  long long ans = 0;
  for (long long i = (0); i < (1 << n); i++) {
    bool f = true;
    for (long long j = (0); j < (m); j++) {
      long long cnt = 0;
      for (long long k = (0); k < (G[j].size()); k++)
        if (i & (1 << G[j][k])) cnt++;
      if (cnt % 2 != p[j]) f = false;
    }
    if (f) ans++;
  }
  cout << ans << endl;
}
