#include <bits/stdc++.h>
int main() {
  int N, M;
  std::cin >> N >> M;
  int k[M];
  std::vector<int> s[M];
  int n = 1;
  for (int i = 0; i < N; ++i) n *= 2;
  for (int i = 0; i < M; ++i) {
    std::cin >> k[i];
    for (int j = 0; j < k[i]; ++j) {
      int tmp = 0;
      std::cin >> tmp;
      s[i].push_back(tmp - 1);
    }
  }
  int p[M];
  for (int i = 0; i < M; ++i) std::cin >> p[i];
  int ans = 0;
  for (int i = 1; i < n; ++i) {
    bool flag = true;
    for (int j = 0; j < M; ++j) {
      int count = 0;
      for (int l = 0; l < k[j]; ++l) {
        if (i & (1 << s[j][l])) {
          count++;
        }
      }
      if (count % 2 != p[j]) {
        flag = false;
        break;
      }
    }
    if (flag) ++ans;
  }
  std::cout << ans << std::endl;
  return 0;
}
