#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long n) {
  if (n == 1) return a;
  if (n == 0) return 1;
  if (n % 2) return a * power(a * a, n / 2);
  return power(a * a, n / 2);
}
const long long md = 998244353;
const long long inf = (long long)1e18;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, p[100];
  cin >> n >> m;
  vector<long long> adj[m + 5];
  for (long long i = 1; i < m + 1; ++i) {
    long long k;
    cin >> k;
    for (long long i = 1; i < k + 1; ++i) {
      long long x;
      cin >> x;
      adj[i].push_back(x - 1);
    }
  }
  long long ans = 0;
  for (long long i = 1; i < m + 1; ++i) cin >> p[i];
  for (long long i = 0; i < (1 << n); ++i) {
    bool fo = 1;
    for (long long j = 1; j < m + 1; ++j) {
      long long c = 0;
      for (auto &x : adj[j]) {
        if (i & (1 << x)) ++c;
      }
      if (c % 2 != p[j] % 2) fo = 0;
    }
    if (fo) ++ans;
  }
  cout << ans;
  return 0;
}
