#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 1000000007;
ll INF = 1000000099;
vector<ll> p(15), c;
vector<vector<ll>> v(15, vector<ll>(15, 0));
signed main() {
  ll n, m, ans = 0;
  cin >> n >> m;
  for (ll i = 0; i < m; i++) {
    ll k;
    cin >> k;
    for (ll j = 0; j < k; j++) {
      ll x;
      cin >> x;
      v.at(i).at(x) = 1;
    }
  }
  for (ll i = 0; i < m; i++) {
    cin >> p.at(i);
  }
  for (int i = 0; i < (1 << n); i++) {
    ll x = i, cnt = 0;
    vector<ll> c(m, 0);
    while (x > 0) {
      if (x % 2 == 1) {
        for (int j = 0; j < m; j++) {
          if (v.at(j).at(cnt) == 1) {
            c.at(j) ^= 1;
            ;
          }
        }
      }
      cnt++;
      x /= 2;
    }
    bool flag = true;
    for (int i = 0; i < m; i++) {
      if (p.at(i) != c.at(i)) {
        flag = false;
        break;
      }
    }
    if (flag) {
      ans++;
    }
  }
  cout << ans << endl;
}
