#include <bits/stdc++.h>
using namespace std;
template <typename T>
void setmax(T& x, T y) {
  x = max(x, y);
}
template <typename T>
void setmin(T& x, T y) {
  x = min(x, y);
}
const double PI = acos(-1.0);
const long long INF = 1e9 + 47;
const long long LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> mask(m, 0);
  for (int i = (0); i < (m); ++i) {
    int k, x;
    cin >> k;
    while (k--) {
      cin >> x;
      x--;
      mask[i] |= 1 << x;
    }
  }
  vector<int> p(m);
  for (int i = (0); i < (m); ++i) cin >> p[i];
  int ans = 0;
  for (int i = (0); i < (1 << n); ++i) {
    bool ok = true;
    for (int j = (0); j < (m); ++j)
      ok &= __builtin_popcount(mask[j] & i) & 1 == p[j];
    ans += ok;
  }
  cout << ans << endl;
  cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
  return 0;
}
