#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007LL;
ll ADD(ll x, ll y) { return (x + y) % MOD; }
ll SUB(ll x, ll y) { return (x - y + MOD) % MOD; }
ll MUL(ll x, ll y) { return x * y % MOD; }
ll POW(ll x, ll e) {
  ll v = 1;
  for (; e; x = MUL(x, x), e >>= 1)
    if (e & 1) v = MUL(v, x);
  return v;
}
ll DIV(ll x, ll y) { return MUL(x, POW(y, MOD - 2)); }
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int n, m;
int k[12];
int s[12][12];
int t[12][12];
int p[12];
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < (int)(m); i++) {
    cin >> k[i];
    for (int j = 0; j < (int)(k[i]); j++) {
      int val;
      cin >> val;
      val--;
      s[i][val]++;
    }
  }
  for (int i = 0; i < (int)(m); i++) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < (int)((1 << n)); bit++) {
    memset(t, 0, sizeof(t));
    for (int j = 0; j < (int)(n); j++) {
      if (bit & (1 << j)) {
        for (int i = 0; i < (int)(m); i++) {
          t[i][j]++;
        }
      }
    }
    int cnt = 0;
    for (int i = 0; i < (int)(m); i++) {
      int sum = 0;
      for (int itr = 0; itr < (int)(k[i]); itr++) {
        if (t[i][itr]) sum++;
      }
      if ((sum) % 2 == p[i]) cnt++;
    }
    if (cnt == m) ans++;
  }
  cout << ans << endl;
  return 0;
}
