#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> conect;
  for (int i = (0); i < (m); ++i) {
    int k;
    cin >> k;
    vector<int> s(k);
    for (int i = (0); i < (k); ++i) {
      cin >> s[i];
    }
    conect.push_back(s);
  }
  vector<int> p(m);
  for (int i = (0); i < (m); ++i) {
    cin >> p[i];
  }
  int res = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    bool ok = true;
    for (int i = (0); i < (m); ++i) {
      int con = 0;
      for (const auto& v : conect[i]) {
        if (bit & (1 << v)) ++con;
      }
      if (con % 2 != p[i]) ok = false;
    }
    if (ok) ++res;
  }
  cout << res << endl;
  return 0;
}
