#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> v(m);
  vector<int> isOn(m);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    v.at(i).push_back(a - 1);
  }
  for (int i = 0; i < m; i++) cin >> isOn.at(i);
  long long res = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool flag = true;
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (auto c : v.at(i)) {
        if (bit & (1 << c)) cnt += 1;
      }
      if (cnt % 2 != isOn.at(i)) flag = false;
    }
    if (flag) res += 1;
  }
  cout << res << endl;
}
