#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<T> &v) {
  for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
    out << v[i] << " ";
  out << "\n";
  return out;
}
template <typename T, typename N>
std::ostream &operator<<(std::ostream &out, vector<pair<T, N> > &v) {
  for (size_t i = 0; i < v.size(); ++i)
    out << "(" << v[i].first << ", " << v[i].second << ") ";
  out << "\n";
  return out;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<vector<T> > &v) {
  for (size_t i = 0; i < v.size(); ++i) {
    for (size_t j = 0; j < v[i].size(); ++j) {
      out << v[i][j] << " ";
    }
    out << "\n";
  }
  return out;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int> > switches(m + 1, vector<int>());
  int k;
  for (int i = 1; i <= m; ++i) {
    cin >> k;
    int s;
    for (int j = 0; j < k; ++j) {
      cin >> s;
      switches[i].push_back(s);
    }
  }
  vector<int> p(m + 1);
  for (int i = 1; i <= m; ++i) {
    cin >> p[i];
  }
  int ways = 0;
  for (int i = 1; i < (1 << n); ++i) {
    vector<int> curr(n + 1);
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) {
        curr[j + 1] = 1;
      }
    }
    bool valid = true;
    for (int j = 1; j <= m; ++j) {
      int on = 0;
      for (int k = 0; k < switches[j].size(); ++k) {
        if (curr[switches[j][k]] == 1) {
          ++on;
        }
      }
      if (on % 2 != p[j]) {
        valid = false;
        break;
      }
    }
    if (valid) {
      ++ways;
    }
  }
  cout << ways << "\n";
  return 0;
}
