#include <bits/stdc++.h>
using namespace std;
using s64 = long long int;
int N, M;
bool sw[10][10];
std::vector<int> p;
bool is_ok(int state) {
  int b[10] = {};
  for (int i = 0; i < N; i++) {
    if (state & (1 << i)) {
      for (int j = 0; j < M; j++) {
        if (sw[j][i]) b[j]++;
      }
    }
  }
  for (int i = 0; i < M; i++) {
    if (b[i] % 2 != p[i]) return false;
  }
  return true;
}
int main() {
  cin >> N >> M;
  for (int m = 0; m < M; m++) {
    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
      int tmp;
      cin >> tmp;
      tmp--;
      sw[m][tmp] = true;
    }
  }
  for (int m = 0; m < N; m++) {
    int pp;
    cin >> pp;
    p.push_back(pp);
  }
  int n = static_cast<int>(pow(2, N));
  int ans = 0;
  for (int i = 0; i < n; i++) {
    bool ok = is_ok(i);
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
