#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class H>
void CIN(H& h) {
  cin >> h;
}
template <class H, class... T>
void CIN(H& h, T&... t) {
  cin >> h;
  CIN(t...);
}
namespace {
template <class T>
void show(T& x) {
  cout << x << " ";
}
template <class T>
void showendl(T& x) {
  cout << x << endl;
}
template <class P, class Q>
void show(pair<P, Q>& x) {
  cout << "(" << x.first << ", " << x.second << ") ";
}
template <class P, class Q>
void showendl(pair<P, Q>& x) {
  cout << "(" << x.first << ", " << x.second << ")" << endl;
}
template <class H>
void debug(H&& h) {
  showendl(h);
}
template <class H, class... Ts>
void debug(H&& h, Ts&&... ts) {
  show(h);
  debug(forward<Ts>(ts)...);
}
template <class T>
void debug(vector<T>& vt) {
  int i = 0;
  for (auto x : vt) ++i != vt.size() ? show(x) : showendl(x);
}
template <class T>
void debug(initializer_list<T> init) {
  int i = 0;
  for (auto x : init) ++i != init.size() ? show(x) : showendl(x);
}
}  // namespace
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int n, m;
  CIN(n, m);
  vvi S(m);
  for (int i = 0; i < (int)m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < (int)k; j++) {
      int s;
      cin >> s;
      s--;
      S[i].push_back(s);
    }
  }
  vi P;
  for (int i = 0; i < (int)m; i++) {
    int p;
    cin >> p;
    P.push_back(p);
  }
  int ans = 0;
  for (int onoff = 1; onoff < (1 << n); onoff++) {
    int rec = 0;
    for (int lamp = 0; lamp < m; lamp++) {
      int num = 0;
      for (int x : S[lamp]) {
        if (1 << x & onoff) num++;
      }
      if (num % 2 == P[lamp]) {
        rec++;
      }
    }
    if (rec == m) ans++;
  }
  debug(ans);
}
