#include <bits/stdc++.h>
using namespace std;

int CountBits(int v, int N) {}

int main() {
  int N, M;
  cin >> N >> M;
  int s[M] = {}, tmps, k, p[M];
  for (int i = 0; i < M; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> tmps;
      s[i] |= 1 << (tmps - 1);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }

  int ans = 0;
  bool all_on;
  for (int i = 1; i < 1 << N; i++) {
    all_on = true;
    for (int j = 0; j < M; j++) {
      int sw_on = s[j] & i;
      int count = 0;
      for (int i = 0; i < N; i++) {
        if (sw_on & (1 << i)) count++;
      }
      if (count % 2 != p[j]) {
        all_on = false;
        break;
      }
    }
    if (!all_on) ans++;
  }

  cout << ans << endl;

  return 0;
}
