#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
int main() {
  ull n, m;
  cin >> n >> m;
  vector<ll> k(m, 0);
  vector<vector<ll>> s(m, vector<ll>(m, 0));
  vector<ll> p(m, 0);
  for (int k_ = 0; k_ < (m); ++k_) {
    cin >> k[k_];
    for (int s_ = 0; s_ < (k[k_]); ++s_) {
      cin >> s[k_][s_];
      s[k_][s_]--;
    }
  }
  for (int p_ = 0; p_ < (m); ++p_) cin >> p[p_];
  ll ans = 0;
  for (int i = 0; i < (1 << (n)); ++i) {
    bool ok = true;
    for (int k_ = 0; k_ < (m); ++k_) {
      int b = 0;
      for (int s_ = 0; s_ < (k[k_]); ++s_) {
        if (((i) & (1 << (s[k_][s_])))) b = b == 0 ? 1 : 0;
      }
      if (b != p[k_]) {
        ok = false;
        break;
      }
    }
    if (ok) ++ans;
  }
  cout << ans << endl;
  return 0;
}
