#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
void view(T cont) {
  std::cout << cont << std::endl;
}
template <typename T>
void view(T* cont, ll sz) {
  for (ll i = 0; i < (ll)(sz); i++) std::cout << cont[i] << " ";
  std::cout << std::endl;
}
template <typename T>
void view(const std::vector<T>& v) {
  for (const auto& f : v) std::cout << f << " ";
  std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T> >& vv) {
  for (const auto& v : vv) {
    view(v);
  }
}
const long long INF = 1LL << 60;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int N, M;
  cin >> N >> M;
  int k[10];
  vector<vector<int> > s;
  for (ll i = 0; i < (ll)(M); i++) {
    cin >> k[i];
    s.push_back(vector<int>{});
    for (ll j = 0; j < (ll)(k[i]); j++) {
      int temp;
      cin >> temp;
      s[i].push_back(temp);
    }
  }
  vector<int> p;
  for (ll i = 0; i < (ll)(M); i++) {
    int temp;
    cin >> temp;
    p.push_back(temp);
  }
  bool switch_on;
  int count = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    switch_on = true;
    for (int i = 0; i < M; i++) {
      int on_num =
          __builtin_popcount(bit & accumulate(s[i].begin(), s[i].end(), 0));
      if (on_num % 2 != p[i]) {
        switch_on = false;
      }
    }
    if (switch_on) count++;
    switch_on = true;
  }
  cout << count << endl;
}
