#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> to(N);
  for (long long i = 0; i < M; i++) {
    long long k;
    cin >> k;
    for (long long j = 0; j < k; j++) {
      long long s;
      to[s] |= 1 << i;
    }
  }
  vector<long long> P(M);
  for (long long k = 0; k < M; k++) {
    cin >> P[k];
  }
  long long cnt = 0;
  for (long long i = 0; i < (1 << N); i++) {
    long long t = 0;
    bool flag = true;
    for (long long j = 0; j < N; j++) {
      if (i >> j & 1) {
        t ^= to[j];
      }
    }
    for (long long k = 0; k < M; k++) {
      if ((t >> k & 1) != (P[k] % 2)) {
        flag = false;
      }
    }
    if (flag) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
