#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long INF = 100000000000;
double PI = 3.1415926535;
template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(N);
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    int k;
    cin >> k;
    L[i] = k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      S[i].push_back(a);
    }
  }
  vector<int> P(M);
  for (int i = 0; i < M; i++) {
    cin >> P[i];
  }
  int ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    bitset<10> B(i);
    vector<int> cnt(M);
    for (int j = 0; j < 10; j++) {
      if (B.test(j)) {
        for (int k = 0; k < L[j]; k++) {
          cnt[S[j][k] - 1]++;
        }
      }
    }
    bool frag = 1;
    for (int i = 0; i < M; i++) {
      if (cnt[i] % 2 != P[i]) {
        frag = 0;
      }
    }
    cout << endl;
    if (frag) {
      ans++;
    }
  }
  cout << ans << endl;
}
