#include <bits/stdc++.h>
const long INF = 1e9;
using namespace std;
template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;
using pi = pair<long, long>;
using vi = vc<long>;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
  long N, M;
  cin >> N >> M;
  vi G[M];
  long A[M];
  for (long i = long(0); i < long(M); i++) {
    long k;
    cin >> k;
    for (long j = long(0); j < long(k); j++) {
      long a;
      cin >> a;
      G[i].emplace_back(a - 1);
    }
  }
  for (long i = long(0); i < long(M); i++) {
    cin >> A[i];
  }
  long cnt = 0;
  for (long i = long(0); i < long(1 << N); i++) {
    bool frag = true;
    for (long j = long(0); j < long(M); j++) {
      long pos = 0;
      for (auto a : G[j]) {
        if ((i >> a) & 1) pos++;
      }
      if ((pos % 2 ^ A[j]) ^ ((i >> j) & 1)) frag = false;
    }
    if (frag) cnt++;
  }
  cout << cnt << endl;
}
