#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  for (int i = 0; i < N; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      s[i] |= (1 << --a);
    }
  }
  vector<int> P(M);
  for (auto &p : P) cin >> p;
  int ans = 0;
  for (int b = 0; b < (1 << N); b++) {
    int ok = 1;
    for (int i = 0; i < M; i++) {
      int bb = b & s[i];
      int cnt = 0;
      while (bb) {
        cnt += (1 & bb);
        bb >>= 1;
      }
      cnt = (cnt & 1);
      if (cnt != P[i]) ok = 0;
    }
    ans += ok;
  }
  cout << ans << endl;
  return 0;
}
