#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int P[100];
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<ll>> S(N);
  for (int i = 0; i < M; ++i) {
    ll k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      ll s;
      cin >> s;
      s--;
      S[s].emplace_back(k - 1);
    }
  }
  for (int i = 0; i < M; ++i) {
    cin >> P[i];
  }
  ll count = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    vector<ll> KON(M, 0);
    for (int i = 0; i < N; ++i) {
      if (bit & (1 << i)) {
        for (auto si : S[i]) {
          KON[si]++;
        }
      }
    }
    bool allon = true;
    for (int i = 0; i < M; ++i) {
      if (KON[i] % 2 != P[i]) {
        allon = false;
        break;
      }
    }
    if (allon) {
      count++;
    }
  }
  cout << count << endl;
  ;
}
