#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline void dump(vector<T> v) {
  for (auto& x : v) cerr << x << " ";
  cerr << endl;
}
template <class T>
inline void dump(vector<pair<T, T>> v) {
  for (auto& p : v) cerr << p.first << " " << p.second << endl;
}
template <class T>
inline void dump(vector<vector<T>> vv) {
  for (auto& v : vv) {
    for (auto& x : v) cerr << x << " ";
    cerr << endl;
  }
}
constexpr int INF = 1e9 + 5;
constexpr long long INFLL = 1LL << 60;
constexpr double eps = (1e-9);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<bool>> con(n, vector<bool>(m, false));
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int i = 0; i < k; ++i) {
      int s;
      cin >> s;
      s--;
      con[s][i] = true;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; ++i) cin >> p[i];
  auto f = [&](const vector<int>& n_on) {
    for (int i = 0; i < m; ++i) {
      if (p[i] != n_on[i] % 2) return false;
    }
    return true;
  };
  ll ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    vector<int> n_on(m, 0);
    for (int i = 0; i < n; ++i) {
      if ((bit >> i) & 1) {
        for (int j = 0; j < m; ++j) {
          if (con[i][j]) n_on[j]++;
        }
      }
    }
    if (f(n_on)) ans++;
  }
  cout << ans << endl;
  return 0;
}
