#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MAX = 100005;
const int MOD = 1000000007;
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) {
  return s << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1) s << "	";
  }
  return s;
}
template <typename T>
ostream &operator<<(ostream &s, const vector<vector<T>> &vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}
long long ans = 0;
long long n, m, k;
vector<long long> swistatus;
vector<vector<long long>> swiconnect;
vector<long long> p;
void dfs(long long i, long long flag, vector<long long> &status) {
  cerr << "i"
       << ":" << i << endl;
  ;
  if (flag) {
    vector<long long> &target = swiconnect[i];
    for (long long i = (0); i < (target.size()); i++) {
      status[target[i]]++;
    }
  }
  if (i < n) {
    dfs(i + 1, 0, status);
    dfs(i + 1, 1, status);
  } else {
    bool comp = true;
    for (long long i = (0); i < (status.size()); i++) {
      if (status[i] % 2 == p[i]) {
        comp = false;
      }
    }
    if (comp) {
      ans++;
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  swistatus.resize(m);
  swiconnect.resize(n + 1);
  p.resize(m);
  for (long long i = (0); i < (m); i++) {
    cin >> k;
    for (long long j = (0); j < (k); j++) {
      long long tmp;
      cin >> tmp;
      swiconnect[tmp].push_back(i);
    }
  }
  for (long long i = (0); i < (m); i++) {
    cin >> p[i];
  }
  dfs(1, 0, swistatus);
  dfs(1, 1, swistatus);
  cout << ans << endl;
  return 0;
}
