#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e18;
signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  bool f[11][11] = {};
  for (long long i = 0; i < m; i++) {
    long long k;
    cin >> k;
    for (long long j = 0; j < k; j++) {
      long long in;
      cin >> in;
      in--;
      f[i][j] = true;
    }
  }
  vector<long long> p(m);
  for (long long i = 0; i < m; i++) cin >> p[i];
  long long ans = 0;
  for (long long mask = 0; mask < (1 << n); mask++) {
    bool g = true;
    for (long long i = 0; i < m; i++) {
      long long cnt = 0;
      for (long long j = 0; j < n; j++) {
        if (f[i][j]) {
          if (mask & (1 << j)) {
            cnt++;
          }
        }
      }
      if (cnt % 2 != p[i]) {
        g = false;
      }
    }
    if (g) ans++;
  }
  cout << ans << endl;
}
