#include <bits/stdc++.h>
using namespace std;
const int MAXBITS = 10;
int bitcount(int val) {
  int ans = 0;
  int bit = 1;
  for (long long i = 0; i < (MAXBITS); i++) {
    if (val & bit) ans++;
    bit <<= 1;
  }
  return ans;
}
int main() {
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> k(m);
  for (long long i = 0; i < (m); i++) {
    int s;
    cin >> s;
    for (int j = 0; j < s; j++) k[i].push_back(s);
  }
  vector<int> p(m);
  for (long long i = 0; i < (m); i++) {
    cin >> p[i];
    p[i] %= 2;
  }
  const int N = 1 << (n);
  vector<bool> gmask(N, true);
  for (long long i = 0; i < (m); i++) {
    int mask = 0;
    for (auto b : k[i]) mask |= 1 << (b - 1);
    for (int j = 0; j < N; j++)
      gmask[j] = gmask[j] && bitcount(mask & j) % 2 == p[i];
  }
  int ans = 0;
  for (long long i = 0; i < (N); i++)
    if (gmask[i]) ans++;
  cout << ans << endl;
}
