#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int M, N;
  cin >> N >> M;
  vector<int> k(M);
  int s[M][N];
  for (int i = 0; i < N; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) cin >> s[i][j];
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) cin >> p[i];
  long long count = 0;
  for (int bits = 0; bits < (1 << N); bits++) {
    for (int i = 0; i < M; i++) {
      long long tmp = 0;
      for (int j = 0; j < k[i]; j++) {
        if (bits & (1 << (s[i][j] - 1))) tmp++;
      }
      if (tmp % 2 != p[i])
        break;
      else if (i == M - 1)
        count++;
    }
  }
  cout << count << endl;
  return 0;
}
