#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> vec(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    vec[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> vec[i][j];
      vec[i][j]--;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  int snum;
  for (int bit = 0; bit < (1 << n); ++bit) {
    　 bool ok = true;
    for (int i = 0; i < m; i++) {
      snum = 0;
      for (int id : vec[i]) {
        if ((bit >> id) & 1) {
          ++snum;
        }
      }
      snum %= 2;
      if (snum != p[i]) {
        ok = false;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
}
