#include <bits/stdc++.h>
using namespace std;
bool isprime(int n) {
  double rootn = sqrt(n);
  if (n < 2) {
    return false;
  } else if (n == 2) {
    return true;
  } else if (n % 2 == 0) {
    return false;
  } else {
    for (int i = 3; i <= rootn; i += 2) {
      if (n % i == 0) {
        return false;
      }
    }
    return true;
  }
}
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime) {
  primes = {};
  is_prime = {};
  for (int i = 0; i <= N; i++) {
    is_prime.push_back(true);
  }
  primes.push_back(2);
  for (int j = 4; j <= N; j += 2) {
    is_prime[j] = false;
  }
  int i;
  for (i = 3; i * i <= N; i += 2) {
    if (!is_prime[i]) continue;
    primes.push_back(i);
    for (int j = 2 * i; j <= N; j += i) {
      is_prime[j] = false;
    }
  }
  for (; i <= N; i += 2) {
    if (is_prime[i]) {
      primes.push_back(i);
    }
  }
}
signed main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m + 1, vector<int>());
  vector<int> k(m + 1);
  for (int i = 1; i <= m; i++) {
    cin >> k[i];
    for (int j = 1; j <= k[i]; j++) {
      int sij;
      cin >> sij;
      s[i].push_back(sij);
    }
  }
  vector<int> p(m);
  for (int i = 1; i <= m; i++) {
    cin >> p[i];
  }
  vector<int> sw(n + 1, 0);
  int n_on = 0;
  for (int i = 0; i < (1 << n); i++) {
    int tempi = i;
    for (int j = 1; j <= n; j++) {
      sw[j] = tempi % 2;
      tempi /= 2;
    }
    int l;
    for (l = 1; l <= m; l++) {
      int cond = 0;
      for (int u = 0; u < k[l]; u++) {
        cond += (sw[s[l][u]] == 1);
      }
      if (cond % 2 != p[l]) {
        break;
      }
    }
    if (l == m + 1) {
      n_on++;
    }
  }
  cout << n_on << endl;
  return 0;
}
