#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll mod(ll a) { return (a % 1000000007); }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
int main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> table(m, vector<ll>(n, 0));
  vector<ll> onscnt(m);
  vector<ll> switchdefault(m);
  vector<ll> oncnt(n);
  ll cnt = 0;
  for (int i = 0; i < (m); i++) {
    ll k;
    cin >> k;
    for (int j = 0; j < (k); j++) {
      ll num;
      cin >> num;
      table[i][num - 1] = 1;
    }
  }
  for (int i = 0; i < (m); i++) cin >> switchdefault[i];
  for (ll bit = 0; bit < (1 << n); ++bit) {
    for (int i = 0; i < (m); i++) {
      onscnt[i] = switchdefault[i];
    }
    for (ll i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        for (int j = 0; j < (m); j++) {
          for (int l = 0; l < (n); l++) {
            if (table[j][l] == 1) {
              onscnt[j]++;
            }
          }
        }
      }
    }
    bool flag = true;
    for (int i = 0; i < (m); i++) {
      if (onscnt[i] % 2 != 0) {
        flag = false;
        break;
      }
    }
    if (flag) cnt++;
  }
  cout << cnt << endl;
}
