#include <bits/stdc++.h>
const long long INF = (long long)1e18 + 1;
const long long MOD = 1e9 + 7;
namespace util {
std::vector<std::string> split(std::string s, char delimiter) {
  std::vector<std::string> vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter)
      vs.push_back(sub), sub.clear();
    else
      sub += c;
  }
  vs.push_back(sub);
  return vs;
}
}  // namespace util
template <class T>
T minimum(T head, T tail) {
  return std::min(head, tail);
}
template <class H, class... T>
H minimum(H head, T... tail) {
  return std::min(head, minimum(tail...));
}
template <class T>
T maximum(T head, T tail) {
  return std::max(head, tail);
}
template <class H, class... T>
H maximum(H head, T... tail) {
  return std::max(head, maximum(tail...));
}
template <class T, class S>
std::ostream& operator<<(std::ostream& os, std::pair<T, S> p) {
  return os << p.first << " " << p.second;
}
template <class T>
std::ostream& operator<<(std::ostream& os, std::vector<T> v) {
  for (long long i = 0; i < (long long)v.size(); i++) {
    os << " [" << i << "]" << v[i];
    if (i % 10 == 9) os << std::endl;
  }
  return os;
}
template <class T, class S>
std::ostream& operator<<(std::ostream& os, std::vector<std::pair<T, S> > vp) {
  long long i = 0;
  for (auto p : vp) {
    os << " [" << i++ << "]" << p.first << " " << p.second;
    if (i % 10 == 0) os << std::endl;
  }
  return os;
}
void print() { std::cout << std::endl; }
template <typename H>
void print(H head) {
  std::cout << head << std::endl;
}
template <typename H, typename... T>
void print(H head, T... tail) {
  std::cout << head << " ", print(tail...);
}
int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  long long N, M;
  std::cin >> N >> M;
  std::vector<long long> vk(M, 0LL);
  std::vector<std::vector<long long> > vs(M);
  for (long long i = 0; i < M; i++) {
    std::cin >> vk[i];
    for (long long j = 0; j < vk[i]; j++) {
      long long s;
      std::cin >> s;
      vs[i].push_back(s);
    }
  }
  std::vector<long long> vp(M, 0LL);
  for (long long i = 0; i < M; i++) {
    std::cin >> vp[i];
  }
  long long ans = 0LL;
  for (long long S = 0; S < std::pow(2, N); S++) {
    bool judge = true;
    for (long long i = 0; i < M; i++) {
      long long cnt = 0LL;
      for (long long j = 0; j < vk[i]; j++) {
        if (S & (1 << j)) {
          cnt++;
        }
      }
      if (cnt % 2 != vp[i]) {
        judge = false;
      }
    }
    if (judge == true) ans++;
  }
  print(ans);
  return 0;
}
