#include <bits/stdc++.h>
using namespace std;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = {0, 0, 1, -1};
const int c_Dy[4] = {1, -1, 0, 0};
int main() {
  int N, M, k[20], s[15][15], p[15];
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++) {
    scanf("%d", &k[i]);
    for (int j = 0; j < k[i]; j++) {
      scanf("%d", &s[i][j]);
    }
  }
  for (int i = 0; i < M; i++) {
    scanf("%d", &p[i]);
  }
  int ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    int swich[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    for (int j = 0; j < N; j++) {
      swich[j] = (i >> j) & 1;
    }
    for (int j = 0; j < M; j++) {
      int onNum = 0;
      for (int m = 0; m < k[j]; m++) {
        onNum += swich[k[j] - 1];
      }
      if (onNum % 2 != p[j]) {
        break;
      } else if (j == M - 1) {
        ans++;
      }
    }
  }
  printf("%d", ans / 2);
}
