#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vstr = vector<string>;
void solve() {
  int N, M;
  cin >> N >> M;
  vi k(M), p(M);
  vector<vi> s;
  for (int i = int(0); i < int(M); i++) {
    cin >> k[i];
    vi sk(k[i]);
    for (int j = int(0); j < int(k[i]); j++) {
      cin >> sk[j];
      sk[j]--;
    }
    s.push_back(sk);
  }
  for (int i = int(0); i < int(M); i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bit = int(1); bit < int(pow(2, N)); bit++) {
    bool ok = 1;
    vi on_switch(N);
    for (int j = int(0); j < int(N); j++) {
      on_switch[j] = (bit >> j & 1);
    }
    for (int j = int(0); j < int(M); j++) {
      int on_count = 0;
      for (auto sij : s[j]) {
        on_count += on_switch[sij];
      }
      if (on_count % 2 != p[j]) {
        ok = 0;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << (ans) << '\n';
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  solve();
  return 0;
}
