#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
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;
}
const int MOD = 1e9 + 7;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m, vector<int>(n, 0));
  vector<int> p(m);
  for (int(i) = (0); (i) < (m); ++i) {
    int k;
    cin >> k;
    for (int(j) = (0); (j) < (k); ++j) {
      int a;
      cin >> a;
      --a;
      s[i][a] = 1;
    }
  }
  for (int(i) = (0); (i) < (m); ++i) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool ok = true;
    int sum = 0;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        if ((bit >> j) & 1) {
          if (s[i][j] == 1) {
            sum++;
          }
        }
      }
      if (sum % 2 != p[i]) {
        ok = false;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
