#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<vector<int> > S;
vector<int> P;
vector<bool> isOn;
int rec(int n) {
  if (n == 0) {
    int ok = 1;
    for (int i = 0; i < M; i++) {
      int cnt = 0;
      for (int j : S[i]) {
        if (isOn[j]) cnt++;
      }
      if (cnt % 2 != P[i]) ok = 0;
    }
    return ok;
  }
  int res = 0;
  res += rec(n - 1);
  isOn[n - 1] = true;
  res += rec(n - 1);
  isOn[n - 1] = false;
  return res;
}
int main() {
  cin >> N >> M;
  S.resize(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int x;
      cin >> x;
      S[i].push_back(x);
    }
  }
  P.resize(M);
  for (int i = 0; i < M; i++) {
    cin >> P[i];
  }
  isOn.resize(N, false);
  cout << rec(N) << endl;
  return 0;
}
