#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int K[15], S[15][15], pair<int, int>[15];
  int i, j, k, l, m, n, o, p, q, r, s, t, u;
  for (int i = 0; i < M; i++) {
    cin >> K[i];
    for (int j = 0; j < K[i]; j++) {
      cin >> S[i][j];
    }
  }
  for (int i = 0; i < M; i++) cin >> pair<int, int>[i];
  int cnt = 1;
  for (int i = 0; i < N; i++) cnt *= 2;
  int zyo[10];
  for (int i = 0; i < 10; i++) zyo[i] = 0;
  int sa[N];
  for (int i = 0; i < N; i++) sa[i] = 0;
  int ans = 0;
  for (int i = 0; i < cnt; i++) {
    bool can = true;
    int tmp = i;
    for (j = 1; j < N; j++) {
      zyo[j] = i % 2;
      tmp /= 2;
    }
    for (int k = 0; k < M; k++) {
      for (int l = 0; l < K[k]; l++) {
        sa[k] += zyo[S[k][l] - 1];
      }
    }
    for (int m = 0; m < M; m++) {
      if (sa[m] % 2 != pair<int, int>[m]) can = false;
    }
    if (can) ans++;
  }
  cout << ans << endl;
}
