#include <bits/stdc++.h>
using namespace std;
void read(long long &N, long long &M, vector<vector<long long>> &g,
          vector<long long> &p);
signed main() {
  long long N, M;
  vector<vector<long long>> to(N);
  vector<long long> p(N);
  read(N, M, to, p);
  long long ans = 0;
  for (long long i = 0, i_len = (1 << N); i < i_len; ++i) {
    vector<long long> bulb(M, 0);
    for (long long j = 0, j_len = (N); j < j_len; ++j) {
      long long bit = (i >> j) & 1;
      if (bit == 1)
        for (long long k = 0, k_len = (to[j].size()); k < k_len; ++k)
          bulb[to[j][k]]++;
    }
    bool ok = true;
    for (long long j = 0, j_len = (M); j < j_len; ++j)
      if (bulb[j] % 2 != p[j]) ok = false;
    if (ok) ans++;
  }
  cout << ans << endl;
}
void read(long long &N, long long &M, vector<vector<long long>> &g,
          vector<long long> &p) {
  cin >> N >> M;
  for (long long i = 0, i_len = (M); i < i_len; ++i) {
    long long k;
    cin >> k;
    for (long long j = 0, j_len = (k); j < j_len; ++j) {
      long long s;
      cin >> s;
      s--;
      g[s].push_back(i);
    }
  }
  for (long long i = 0, i_len = (M); i < i_len; ++i) cin >> p[i];
}
