#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
int N, M;
int k[20];
int s[20][20];
int p[20];
int ans;
int state[10];
bool check() {
  for (int i = 0; i < N; i++) {
    ll num = 0;
    for (int j = 0; j < N; j++) {
      num += s[i][j] * state[j];
    }
    if (num % 2 != p[i]) {
      return false;
    }
  }
  return true;
}
void dfs(int depth) {
  if (depth >= N) {
    if (check()) ans++;
    return;
  } else {
    state[depth] = 1;
    dfs(depth + 1);
    state[depth] = 0;
    dfs(depth + 1);
  }
}
int main() {
  ans = 0;
  Fill(s, 0);
  cin >> N >> M;
  ll S;
  for (ll i = 0; i < N; i++) {
    cin >> k[i];
    for (ll j = 0; j < k[i]; j++) {
      cin >> S;
      s[i][S - 1] = 1;
    }
  }
  for (ll i = 0; i < M; i++) {
    cin >> p[i];
  }
  dfs(0);
  cout << ans << "\n";
  return 0;
}
