#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m;
  ll ans = 0;
  cin >> n >> m;
  vector<ll> a(n);
  for (int i = 0; i < (int)(m); i++) {
    ll k;
    cin >> k;
    for (int j = 0; j < (int)(k); j++) {
      ll s;
      cin >> s;
      s--;
      a[s] |= 1 << i;
    }
  }
  for (int s = 0; s < (1 << n); s++) {
    ll t = 0;
    for (int y = 0; y < (int)(n); y++) {
      if (s >> y & 1) {
        t ^= a[y];
      }
    }
    ll p = 0;
    for (int i = 0; i < (int)(m); i++) {
      int x;
      cin >> x;
      p |= x << i;
    }
    if (t == p) {
      ans++;
    }
  }
  cout << ans;
}
