#include <bits/stdc++.h>
int main(void) {
  int N, M;
  std::cin >> N >> M;
  std::vector<std::vector<int>> switchSet(M);
  for (int i = 0; i < M; ++i) {
    int k;
    std::cin >> k;
    switchSet[i].resize(k);
    for (int j = 0; j < k; ++j) {
      std::cin >> switchSet[i][j];
      --switchSet[i][j];
    }
  }
  std::vector<int> P(M);
  for (int i = 0; i < M; ++i) std::cin >> P[i];
  int count = 0;
  for (int i = 0; i < (1 << N); ++i) {
    bool ok = true;
    for (int j = 0; j < M; ++j) {
      int c = 0;
      for (int id : switchSet[j]) {
        if ((i >> id) & 1) ++c;
      }
      if (c % 2 != P[j]) {
        ok = false;
        break;
      }
    }
    if (ok) ++count;
  }
  return count;
}
