#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  return os;
}
int main() {
  int n, m, k, tmp, result;
  cin >> n >> m;
  vector<vector<int>> v;
  vector<int> s;
  for (int i = 0; i < m; ++i) {
    cin >> k;
    vector<int> _v;
    for (int j = 0; j < k; ++j) {
      cin >> tmp;
      _v.emplace_back(tmp);
    }
    v.emplace_back(_v);
  }
  for (int i = 0; i < m; ++i) {
    cin >> tmp;
    s.emplace_back(tmp);
  }
  for (int i = 0; i < (1 << n); ++i) {
    int flag = 0;
    for (int j = 0; j < (int)(v.size()); j++) {
      int num = 0;
      for (int k = 0; k < (int)(v[j].size()); k++) {
        for (int l = 0; l < (int)(n); l++) {
          if (i & (1 << l)) {
            if (l + 1 == v[j][k]) ++num;
          }
        }
      }
      if (num % 2 == s[j]) ++flag;
    }
    if (flag == m) ++result;
  }
  cout << result << endl;
}
