#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m, k, si, ans = 0, B, f;
  cin >> n >> m;
  B = 1 << n;
  vector<int> s[m], p(m), count(m);
  for (int i = 0; i < m; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> si;
      si--;
      s[i].emplace_back(si);
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < B; i++) {
    f = 1;
    for (int j = 0; j < m; j++) {
      count[i] = 0;
    }
    for (int j = 0; j < m; j++) {
      for (auto x : s[j]) {
        if ((i >> x) & 1) {
          count[x]++;
        }
      }
    }
    for (int i = 0; i < m; i++) {
      if (count[i] % 2 != p[i]) {
        f = 0;
      }
    }
    if (f) {
      ans++;
    }
  }
  cout << ans;
}
