#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  int swnum[10][10] = {};
  for (int i = 0; i < M; i++) {
    scanf("%d", &swnum[i][0]);
    for (int j = 1; j <= swnum[i][0]; j++) {
      scanf("%d", &swnum[i][j]);
    }
  }
  int cond[10] = {};
  for (int i = 0; i < M; i++) {
    scanf("%d", &cond[i]);
  }
  int swcnb = pow(2, N);
  int onconb = 0;
  for (int i = 0; i < swcnb; i++) {
    int swcond[10] = {};
    int temp = i;
    for (int s = 0; s < N; s++) {
      swcond[N - 1 - s] = (temp >= pow(2, N - 1 - s)) ? 1 : 0;
      if (temp >= pow(2, N - 1 - s)) {
        temp -= pow(2, N - 1 - s);
      }
    }
    int lampcount = 0;
    for (int j = 0; j < M; j++) {
      int count = 0;
      for (int k = 1; k <= swnum[j][0]; k++) {
        if (swcond[swnum[j][k] - 1] == 1) {
          count++;
        }
      }
      if (count % 2 == cond[j]) {
        lampcount++;
      } else {
        break;
      }
      if (lampcount == M) {
        onconb++;
      }
    }
  }
  printf("%d", onconb);
}
