#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
long long N, M;
signed main() {
  cin >> N >> M;
  vector<long long> s(N);
  for (long long i = 0; i < (M); i++) {
    long long k;
    cin >> k;
    for (long long j = 0; j < (k); j++) {
      long long temp;
      cin >> temp;
      temp--;
      s[temp] |= (1 << i);
    }
  }
  long long p = 0;
  for (long long i = 0; i < (M); i++) {
    long long temp;
    cin >> temp;
    p |= (temp << i);
  }
  long long ans = 0;
  for (long long i = 0; i < (1 << N); i++) {
    long long t = 0;
    for (long long j = 0; j < N; j++) {
      if (i >> j && 1) {
        t ^= s[j];
      }
    }
    if (p == t) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
