#include <bits/stdc++.h>
int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<std::vector<int>> s(M);
  std::vector<int> p(M);
  for (int i = 0; i < M; i++) {
    int k;
    std::cin >> k;
    std::vector<int> S_k(k);
    for (int j = 0; j < k; j++) std::cin >> S_k[j];
    s[i] = S_k;
  }
  for (int i = 0; i < M; i++) std::cin >> p[i];
  int cnt = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    std::vector<bool> OnSwitch(N, false);
    for (int i = 0; i < N; i++) {
      if (bit & (1 << i)) OnSwitch[i] = true;
    }
    for (int i = 0; i < M; i++) {
      int OnSiwtchNum = 0;
      for (int k = 0; k < s[i].size(); k++) {
        OnSiwtchNum += OnSwitch[s[i][k]];
      }
      if (OnSiwtchNum % 2 != p[i]) break;
      if (i == M - 1) cnt++;
    }
  }
  std::cout << cnt << std::endl;
  return 0;
}
