#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  long long g = gcd(a, b);
  return a / g * b;
}
template <typename T>
T binarysearch(vector<T> A, T key) {
  long long left = 0;
  long long right = 4;
  long long mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (key == A[mid]) return 1;
    if (key > A[mid])
      left = mid + 1;
    else if (key < A[mid])
      right = mid;
  }
  return 0;
}
template <typename T>
T finder(vector<T> vec, T number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) {
    return 1;
  } else {
    return 0;
  }
}
long long frac(long long n) {
  if (n == 0) {
    return 1;
  }
  return (n * frac(n - 1)) % MOD;
}
template <typename T>
T keta(T a) {
  long long kazu = 1;
  while (1) {
    if (a / 10 != 0) {
      a /= 10;
      kazu++;
    } else
      break;
  }
  return kazu;
}
template <typename T>
bool IsPrime(T num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      return false;
    }
  }
  return true;
}
template <typename T>
T nCr(long long n, T r) {
  long long ans = 1;
  for (int i = n; i > n - r; --i) {
    ans = ans * i;
  }
  for (int i = 1; i < r + 1; ++i) {
    ans = ans / i;
  }
  return ans;
}
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> k(M + 1), p(M + 1);
  vector<vector<long long>> data(M + 1);
  long long a = 0;
  for (long long i = 0; i <= M; i++) {
    cin >> k[i];
    data[i].resize(k[i] + 1);
    for (long long j = 1; j <= k[i]; j++) {
      cin >> a;
      a--;
      data[i][j] = a;
    }
  }
  long long bulb;
  long long ans = 0;
  bool ok = true;
  for (long long i = 1; i <= M; i++) cin >> p[i];
  for (long long bit = 1; bit < (1 << N); bit++) {
    ok = true;
    for (long long i = 1; i <= M; i++) {
      bulb = 0;
      for (long long j = 1; j <= k[i]; j++) {
        if (bit & (1 << data[i][j])) {
          bulb++;
        }
      }
      if (bulb % 2 != p[i]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
