#include <bits/stdc++.h>
using namespace std;
vector<int> de(int n) {
  vector<int> vc;
  while (n > 0) {
    vc.push_back(n % 2);
    n = n / 2;
  }
  reverse((vc).begin(), (vc).end());
  return vc;
}
void solve() {
  int n, m;
  cin >> n >> m;
  int p[12];
  int sw[12];
  vector<int> b[12];
  for (int i = 1; i < m + 1; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int t;
      cin >> t;
      b[i].push_back(t);
    }
  }
  for (int i = 1; i < m + 1; i++) cin >> p[i];
  int cnt = 0, f = 1;
  int swpow = pow(2, n);
  for (int i = 0; i < swpow; i++) {
    vector<int> v = de(i);
    f = 1;
    for (int i = 0; i < 12; i++) sw[i] = 0;
    for (int i = 0; i < (int)v.size(); i++) sw[n - (int)v.size() + i] = v[i];
    for (int j = 1; j < m + 1; j++) {
      int add = 0;
      for (int mm = 0; mm < (int)b[j].size(); mm++) {
        add += sw[b[j][mm]];
      }
      if (add % 2 == p[j])
        continue;
      else {
        f = 0;
        break;
      }
    }
    if (f) cnt++;
  }
  cout << cnt << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
