#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
const int INF = 0x3f3f3f3f, N = 15;
const ll LINF = 1e18 + 5;
int n, m, cnt[N];
bool state[N];
vector<int> p[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int k;
    cin >> k;
    while (k--) {
      int s;
      cin >> s;
      p[s - 1].push_back(i);
    }
  }
  for (int i = 1; i <= m; i++) cin >> state[i];
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < n; j++) {
      if ((i >> j) & 1) {
        for (int k : p[j]) {
          cnt[k] ^= 1;
        }
      }
    }
    bool ok = 1;
    for (int i = 1; i <= m; i++) {
      if (!(state[i] ^ cnt[i])) ok = 0;
      cnt[i] = 0;
    }
    ans += ok;
  }
  cout << ans;
  return 0;
}
