#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<bool>> g(n, vector<bool>(m, false));
  for (long long i = 0; i < (m); ++i) {
    int k;
    cin >> k;
    for (long long j = 0; j < (k); ++j) {
      int s;
      cin >> s;
      s--;
      g[i][s] = true;
    }
  }
  vector<int> p(m);
  for (long long i = 0; i < (m); ++i) cin >> p[i];
  long long ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    vector<int> a(m, 0);
    for (long long i = 0; i < (n); ++i) {
      if (bit & (1 << i)) {
        for (long long j = 0; j < (m); ++j) {
          if (g[i][j]) a[j] ^= 1;
        }
      }
    }
    bool jud = true;
    for (long long i = 0; i < (m); ++i) {
      if (p[i] != a[i]) jud = false;
    }
    if (jud) ans++;
  }
  cout << ans << endl;
}
