#include <bits/stdc++.h>
using namespace std;
template <typename T>
T mod(T a, T b) {
  return (a + b) % b;
}
template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
map<long long, long long> factor(long long n) {
  map<long long, long long> mp;
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n > 1) {
    mp[n]++;
  }
  return mp;
}
void solve() {
  int N, M;
  cin >> N >> M;
  vector<int> ks(M);
  int sw[10][10];
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    ks[i] = k;
    for (int j = 0; j < k; j++) {
      cin >> sw[i][j];
      sw[i][j]--;
    }
  }
  int p[10];
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  long long ans = 0;
  for (int itr = 0; itr < (1 << N); itr++) {
    vector<int> S(N);
    for (int j = 0; j < N; j++) {
      if ((itr >> j) & 1) {
        S[j] = 1;
      } else {
        S[j] = 0;
      }
    }
    int cnt = 0;
    int state = 1;
    for (int j = 0; j < M; j++) {
      for (int k = 0; k < ks[j]; k++) {
        cnt += S[sw[j][k]];
      }
      state *= ((cnt % 2) == p[j]);
    }
    if (state) ans++;
  }
  cout << ans << endl;
  return;
}
int main(int argc, char const* argv[]) {
  solve();
  return 0;
}
