#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vi64 = vector<int64_t>;
using vvi64 = vector<vi64>;
const int64_t inf = (int64_t)1e18;
const int64_t mod = (int64_t)1e9 + 7;
int N, M;
vvi ss;
vi ps;
int solve(int i, vector<bool> lights) {
  if (i == N) {
    int res = 0;
    int cnt = 0;
    for (int64_t j = 0; j < (M); ++j) {
      for (int64_t k = 0; k < (ss[j].size()); ++k) {
        cnt += lights[ss[j][k]] ? 1 : 0;
      }
      if (cnt % 2 == ps[j]) res++;
    }
    return res == M ? 1 : 0;
  }
  int res = 0;
  res += solve(i + 1, lights);
  lights[i] = true;
  res += solve(i + 1, lights);
  return res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  ss.assign(M, vi());
  for (int64_t i = 0; i < (M); ++i) {
    int k;
    cin >> k;
    for (int64_t j = 0; j < (k); ++j) {
      int s;
      cin >> s;
      s--;
      ss[i].push_back(s);
    }
  }
  ps.assign(M, 0);
  for (int64_t i = 0; i < (M); ++i) cin >> ps[i];
  cout << solve(0, vector<bool>(N, false)) << endl;
  return 0;
}
