#include <bits/stdc++.h>
using namespace std;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
template <typename T>
void outputVec(const std::vector<T>& vec, const int precision = 0) {
  if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
  for (auto it = vec.begin(); it != vec.end() - 1; ++it) {
    std::cout << *it << " ";
  }
  std::cout << *(vec.end() - 1) << "\n";
}
template <typename T>
void outputVal(const T& res, const int precision = 0) {
  if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
  std::cout << res << "\n";
}
template <typename T>
T inputVal() {
  T a;
  std::cin >> a;
  return a;
}
template <typename T>
std::vector<T> inputVec(int N) {
  std::vector<T> vec(N);
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cin >> *it;
  }
  return vec;
}
template <typename T>
void inputVec(std::vector<T>& vec) {
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cin >> *it;
  }
}
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;
}
void dfs(int nbSw, vector<vector<int> >& sw, vector<int>& ps, vector<int> ls,
         int& cnt, int N, int M) {
  if (nbSw == N - 1) {
    bool isAll = true;
    for (int i = 0; i < M; ++i) {
      int cntSw = 0;
      for (int j = 0; j < N; ++j) {
        cntSw += sw[i][j] * ls[j];
      }
      if (cntSw % 2 == ps[i]) {
        isAll = false;
        break;
      }
    }
    if (isAll) ++cnt;
  } else {
    ls[nbSw] = 0;
    dfs(nbSw + 1, sw, ps, ls, cnt, N, M);
    ls[nbSw] = 1;
    dfs(nbSw + 1, sw, ps, ls, cnt, N, M);
  }
}
void Main() {
  const int N = inputVal<int>();
  const int M = inputVal<int>();
  vector<vector<int> > sw(M, vector<int>(N, 0));
  for (int i = 0; i < M; ++i) {
    int k;
    cin >> k;
    --k;
    for (int j = 0; j < k; ++j) {
      int s;
      cin >> s;
      --s;
      sw[i][s] = 1;
    }
  }
  vector<int> ps(M, 0);
  for (int i = 0; i < M; ++i) {
    cin >> ps[i];
  }
  vector<int> ls(M, 0);
  int cnt = 0;
  dfs(0, sw, ps, ls, cnt, N, M);
  cout << cnt << endl;
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}
