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