#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long linf = 1e18;
const long long mod = 1e9 + 7;
int is_on(int s, int N, int iter) { return (s >> (N - iter)) % 2; }
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s(M, vector<int>(10, 0));
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  vector<int> p(M);
  for (int i = 0; i < N; i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    vector<int> on(N, 0);
    for (int j = 0; j < N; j++) on[j] = is_on(i, N, j + 1);
    int num_on = 0;
    for (int j = 0; j < N; j++) {
      int num_switch = 0;
      for (int l = 0; l < k[j]; l++) {
        num_switch += on[s[j][l] - 1];
      }
      if (num_switch % 2 == p[j]) num_on++;
    }
    if (num_on == M) ans++;
  }
  cout << ans << endl;
  return 0;
}
