#include <bits/stdc++.h>
using namespace std;
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }
const int INF = 1e9;
int count = 0;
int n, m;
vector<int> swi(n);
int ans = 0;
vector<int> p(m);
vector<vector<int>> ks(m, vector<int>(n));
void dfs(int depth) {
  if (depth == n) {
    int sum = accumulate((swi).begin(), (swi).end(), 0);
    for (int i = 0; i < (m); i++) {
      if (sum % 2 != p[i]) return;
    }
    ans++;
    return;
  }
  swi[depth] = 1;
  dfs(depth++);
  swi[depth] = 0;
  dfs(depth++);
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < (m); i++) {
    for (int j = 0; j < (n); j++) {
      cin >> ks[i][j];
    }
  }
  for (int i = 0; i < (m); i++) cin >> p[i];
  dfs(0);
  cout << ans << endl;
  return 0;
}
