#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long modinv(long long a, long long m = MOD) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
int main() {
  int N, M;
  cin >> N >> M;
  int p[11];
  int s[11][11];
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++) s[i][j] = -1;
  int k[11];
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) cin >> s[i][j];
  }
  for (int i = 0; i < M; i++) cin >> p[i];
  long long ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    bool flag = true;
    int tmp[11];
    memset(tmp, 0, 10 * sizeof(int));
    for (int bit = 0; bit < M; bit++) {
      if (i & (1 << bit)) {
        tmp[bit] = 1;
      }
    }
    for (int i = 0; i < M; i++) {
      int count = 0;
      for (int j = 0; j < k[i]; j++) {
        if (tmp[s[i][j] - 1] == 1) {
          count++;
        }
      }
      if ((count % 2) != p[i]) flag = false;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
