#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long to, cost;
};
long long n, m;
long long p[11];
long long ans = 0;
vector<long long> v[11];
signed main() {
  cin >> n >> m;
  for (long long i = 0; i < (long long)(m); i++) {
    long long k;
    cin >> k;
    for (long long j = 0; j < (long long)(k); j++) {
      long long s;
      cin >> s;
      v[i].push_back(s);
    }
  }
  for (long long i = 0; i < (long long)(m); i++) {
    cin >> p[i];
  }
  for (long long i = 0; i < (long long)((1 << n)); i++) {
    long long cnt[11];
    for (long long j = 0; j < (long long)(m); j++) cnt[j] = 0;
    for (long long j = 0; j < (long long)(n); j++) {
      if ((i >> j) & 1) {
        for (long long k = 0; k < (long long)(m); k++) {
          if (binary_search(v[k].begin(), v[k].end(), j + 1)) {
            cnt[k]++;
          }
        }
      }
    }
    bool can = true;
    for (long long j = 0; j < (long long)(m); j++) {
      if (cnt[j] % 2 != p[j]) can = false;
    }
    if (can) ans++;
  }
  cout << ans << endl;
}
