#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<vector<long long> > s(M);
  vector<long long> p;
  vector<long long> K;
  long long i, j, k, l;
  long long ans = 0;
  for (int i = 0; i < M; i++) {
    cin >> K[i];
    for (int j = 0; j < K[i]; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for (int i = 0; i < M; i++) {
    long long b;
    cin >> b;
    p.push_back(b);
  }
  for (int i = 0; i < 1 << N; i++) {
    bool ok = true;
    for (int j = 0; j < M; j++) {
      int cnt = 0;
      for (int k = 0; k < K[j]; k++) {
        if ((i >> s[j][k]) & 1) cnt++;
      }
      if (cnt % 2 != p.at(j)) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
