#include <bits/stdc++.h>
using namespace std;
int main() {
  long N, M;
  cin >> N >> M;
  long k[100], s[100][100];
  for (int i = 1; i <= M; i++) {
    cin >> k[i];
    for (int j = 1; j <= k[i]; j++) cin >> s[i][j];
  }
  long p[100];
  for (int i = 1; i <= M; i++) cin >> p[i];
  bool b[100];
  long oncount = 0;
  long res = 0;
  for (int mybit = 0; mybit < (1 << N); mybit++) {
    for (int i = 1; i <= N; i++) b[i] = false;
    for (int keta = 0; keta < N; keta++)
      if (mybit & (1 << keta)) b[keta + 1] = true;
    oncount = 0;
    for (int i = 1; i <= M; i++) {
      for (int j = 1; j <= k[i]; j++)
        if (b[s[i][j]]) oncount++;
      if (oncount % 2 != p[i]) break;
      if (i == M) res++;
    }
  }
  cout << res << endl;
}
