#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> sw(n);
  for (int i = 0; i < (m); i++) {
    int k;
    cin >> k;
    for (int j = 0; j < (k); j++) {
      int s;
      cin >> s;
      sw[s - 1].push_back(i);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < (m); i++) cin >> p[i];
  int ans = 0;
  for (int bit = 1; bit < (1 << n); bit++) {
    vector<int> cnt(m);
    for (int i = 0; i < (n); i++) {
      if (bit & (1 << i)) {
        for (auto a : sw[i]) cnt[a]++;
      }
    }
    bool ok = true;
    for (int i = 0; i < (m); i++)
      if (cnt[i] % 2 != p[i]) ok = false;
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
