#include <bits/stdc++.h>
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  long long n, m, ans = 0;
  cin >> n >> m;
  vector<long long> k(n), p(m);
  vector<vector<long long>> s(n, vector<long long>());
  for (long long i = 0, i_len = (long long)(m); i < i_len; i++) {
    cin >> k[i];
    s[i].resize(k[i]);
    for (long long j = 0, j_len = (long long)(k[i]); j < j_len; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for (long long i = 0, i_len = (long long)(m); i < i_len; i++) cin >> p[i];
  for (long long bit = 0; bit < (1LL << (n)); bit++) {
    vector<bool> sw(n, false);
    vector<bool> light(m, false);
    for (long long j = 0, j_len = (long long)(n); j < j_len; j++) {
      long long mask = (1LL << j);
      if (bit & mask) sw[j] = true;
    }
    for (long long i = 0, i_len = (long long)(m); i < i_len; i++) {
      long long cnt = 0;
      for (long long j = 0, j_len = (long long)(k[i]); j < j_len; j++)
        if (sw[s[i][j]]) cnt++;
      if (cnt % 2 == p[i]) light[i] = true;
    }
    bool tmp = 1;
    for (long long i = 0, i_len = (long long)(m); i < i_len; i++)
      tmp = tmp & light[i];
    ans += tmp;
  }
  cout << ans << "\n";
}
