#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> s(N, vector<int>());
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int n;
      cin >> n;
      n--;
      s[n].push_back(i);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) cin >> p[i];
  int ans = 0;
  for (int i = (1 << N); i >= 0; i--) {
    bitset<10> state(i);
    vector<int> cnt(M, 0);
    for (int j = 0; j < N; j++) {
      if (state[j] == false) continue;
      for (auto index : s[j]) cnt[index]++;
    }
    bool ok = true;
    for (int j = 0; j < M; j++) {
      ok &= (cnt[j] % 2 == p[j]);
    }
    if (ok == true) ans++;
  }
  cout << ans << endl;
  return 0;
}
