#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ll N, M;
  cin >> N >> M;
  vector<int> S[M];
  for (int i = 0; i < (M); ++i) {
    ll k;
    cin >> k;
    vector<int> A(k);
    for (int i = 0; i < (k); ++i) cin >> A[i];
    for (int i = 0; i < (k); ++i) --A[i];
    S[i] = A;
  }
  vector<int> L(N);
  for (int i = 0; i < (N); ++i) cin >> L[i];
  ll ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    vector<int> cnt(M);
    for (int i = 0; i < N; i++) {
      if ((bit >> i) & 1) {
        for (int j = 0; j < M; j++) {
          if (count(S[j].begin(), S[j].end(), i)) {
            cnt[j] ^= 1;
          }
        }
      }
    }
    if (accumulate(cnt.begin(), cnt.end(), 0) == M) ans++;
  }
  cout << ans << '\n';
  return 0;
}
