#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int res = 0;
  int a[M + 7][N + 7];
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    a[i][0] = k;
    for (int j = 1; j <= k; j++) {
      cin >> a[i][j];
    }
  }
  int b[M + 1];
  for (int i = 0; i < M; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < pow(2, N); i++) {
    int bulbs = 0;
    for (int j = 0; j < M; j++) {
      int t = a[j][0];
      int switches = 0;
      for (int p = 1; p <= t; p++) {
        int o = 1 << (M - a[j][p]);
        int l = o & i;
        if (l > 0) switches++;
      }
      if (switches % 2 == b[j]) bulbs++;
    }
    if (bulbs == M) res++;
  }
  cout << res;
  return 0;
}
