#include <bits/stdc++.h>
using namespace std;
string ans;
const int N = 10;
const int M = 10;
int sum;
vector<int> k(M);
vector<int> p(M);
vector<vector<int>> date(M, vector<int>(N));
int dfs(int a, int b, string ans, int d) {
  if (d == M) {
    int x = 0;
    int y = 0;
    int chk = 0;
    for (int k = 0; k < N; k++) {
      if (ans[k] == 'A') {
        x++;
      } else {
        y++;
      }
    }
    for (int l = 0; l < M; l++) {
      int sum2 = 0;
      for (int q = 0; q < N; q++) {
        if (ans[date[l][q]] == 'A') {
          sum2++;
        }
      }
      if (sum2 % 2 == p[l]) {
        chk++;
      }
    }
    if (chk == M) {
      return sum++;
    }
  }
  ans[d - 1] = 'A';
  int m = dfs(a + 1, b, ans, d + 1);
  return m;
  ans[d - 1] = 'B';
  int n = dfs(a, b + 1, ans, d + 1);
  return n;
}
int main() {
  int N, M;
  string ans;
  int sum = 0;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < N; j++) {
      cin >> date[i][j];
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int solve = dfs(0, 0, ans, 1);
  cout << solve << endl;
}
