#include <bits/stdc++.h>
static inline int bitcount(int x) {
  x = (x & 0x55555555) + ((x >> 1) & 0x55555555);
  x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  x = (x & 0x0F0F0F0F) + ((x >> 4) & 0x0F0F0F0F);
  x = (x & 0x00FF00FF) + ((x >> 8) & 0x00FF00FF);
  x = (x & 0x0000FFFF) + ((x >> 16) & 0x0000FFFF);
  return x;
}
int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<int> mask(M), p(M);
  for (int i = 0; i < M; i++) {
    int k, s, m = 0;
    std::cin >> k;
    for (; k != 0; k--) {
      std::cin >> s;
      m |= (1 << s);
    }
    mask[i] = m;
  }
  for (int i = 0; i < M; i++) std::cin >> p[i];
  int ans = 1 << N;
  for (int sw = 0; sw < (1 << N); sw++) {
    for (int i = 0; i < M; i++) {
      if ((bitcount(sw & mask[i]) & 1) != p[i]) {
        ans--;
        break;
      }
    }
  }
  std::cout << ans;
  return 0;
}
