#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> s(m, 0);
  for (ll i = 0; i < m; ++i) {
    ll k;
    cin >> k;
    for (ll j = 0; j < k; ++j) {
      ll s_i;
      cin >> s_i;
      s_i--;
      s[j] += (1 << s_i);
    }
  }
  ll p = 0;
  for (ll i = 0; i < m; ++i) {
    ll p_i;
    cin >> p_i;
    p += (1 << i) * p_i;
  }
  ll ans = 0;
  for (ll i = 0; i < (1 << n); ++i) {
    ll res = 0;
    for (ll j = 0; j < m; ++j) {
      ll and_s = (i & s[j]);
      ll cnt = 0;
      for (ll k = 0; k < n; ++k) {
        if ((1 << k) & and_s) cnt++;
      }
      res += (1 << j) * (cnt % 2);
    }
    if (res == p) ans++;
  }
  cout << ans << endl;
}
