#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int k[20][20], p[20], r[int(pow(2, N))];
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < N; j++) {
      cin >> k[i][j];
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  for (int h = 0; h < pow(2, N); h++) {
    r[h] = 1;
  }
  for (int i = 0; i < M; i++) {
    for (int h = 0; h < pow(2, N); h++) {
      int sum = 0;
      for (int j = 1; j < k[i][0]; j++) {
        sum += h % (int(pow(2, N - k[i][j])));
      }
      if ((sum % 2) != p[i]) {
        r[h] = 0;
      }
    }
  }
  cout << accumulate(r, r + (sizeof(r) / sizeof(r[0])), 0) << endl;
}
