#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(m, vector<int>());
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    g[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> g[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int mask = 1;
  map<int, int> mp;
  int ans = 0;
  while (mask < (1 << n)) {
    mp.clear();
    for (int i = 0; i < n; i++) {
      if (mask & (1 << i)) {
        mp[i + 1] = 1;
      }
    }
    bool ok = true;
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (int j = 0; j < g[i].size(); j++) {
        if (mp[g[i][j]] == 1) {
          cnt++;
        }
      }
      if ((cnt % 2) != p[i]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      ans++;
    }
    mask++;
  }
  cout << ans;
  return 0;
}
