#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> vec(m);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    vec[i].resize(k);
    for (int j = 0; j < k; ++j) {
      cin >> vec[i][j];
      --vec[i][j];
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool ok = true;
    for (int j = 0; j < m; ++j) {
      int count = 0;
      for (int id = 0; id < vec[j].size(); ++id) {
        if ((bit >> id) & 1) count++;
      }
      if (count % 2 != p[j]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
