#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (ll i = (0), __last_i = (v.size()); i < __last_i; i++) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
  for (ll i = (0), __last_i = (v.size()); i < __last_i; i++) {
    if (i) os << endl;
    os << v[i];
  }
  return os;
}
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 argc, const char* argv[]) {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> s(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    s[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) cin >> p[i];
  int Ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    for (int m = 0; m < M; m++) {
      int count = 0;
      bool isLightOn = true;
      for (int k = 0; k < (int)s[m].size(); k++) {
        if (bit & (1 << s[m][k])) ++count;
        if (count % 2 != p[m]) isLightOn = false;
        if (isLightOn) Ans++;
      }
    }
  }
  cout << Ans << endl;
}
