#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ",";
    os << *it;
  }
  return os << "}";
}
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& v) {
  os << "{";
  os << v.first << ", " << v.second;
  return os << "}";
}
using point = complex<double>;
using ll = int64_t;
int my_main(int argc, char** argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int p;
      cin >> p;
      s[i].push_back(p - 1);
    }
  }
  vector<int> p(m);
  for (int& i : p) cin >> i;
  int ret = 0;
  for (int c = 0; c <= (1 << n); c++) {
    bool ok = true;
    for (int i = 0; i < m; i++) {
      int r = 0;
      for (int si : s[i]) {
        if (c & (1 << si)) r++;
      }
      if (r % 2 != p[i]) ok = false;
    }
    if (ok) ret++;
  }
  cout << ret << endl;
  return 0;
}
int main(int argc, char** argv) { return my_main(argc, argv); }
