#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int ans;
int main(void) {
  cin >> n >> m;
  vector<vector<int> > vec(m);
  for (int i = 0; i < m; i++) {
    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];
  for (int bit = 0; bit < (1 << n); bit++) {
    bool flag = true;
    for (int i = 0; i < n; i++) {
      int count = 0;
      for (auto j : vec[i]) {
        if ((bit >> j) & 1) count++;
      }
      count %= 2;
      if (count != p[i]) flag = false;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
