#include <bits/stdc++.h>
using namespace std;
template <typename T>
string printVector(const vector<T> &data) {
  stringstream ss;
  ostream_iterator<T> out_it(ss, ", ");
  ss << "[";
  std::copy(data.begin(), data.end() - 1, out_it);
  ss << data.back() << "]";
  return ss.str();
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m;
  vector<vector<int>> switches;
  vector<int> p;
  for (int i = 0; i < m; ++i) {
    vector<int> input_switches;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int t;
      cin >> t;
      input_switches.push_back(t);
    }
    switches.push_back(input_switches);
  }
  for (int i = 0; i < m; ++i) {
    int t;
    cin >> t;
    p.push_back(t);
  }
  int ans = 0;
  for (int i = 0; i <= pow(2, n); ++i) {
    int ok = 0;
    for (int j = 0; j < m; ++j) {
      int acc = 0;
      for (auto x : switches[j]) {
        if (i & (1 << (x - 1))) {
          acc++;
        }
      }
      if (acc % 2 == p[j]) {
        ok++;
      }
    }
    if (ok == m) ans++;
  }
  cout << ans << endl;
}
