#include <bits/stdc++.h>
using namespace std;
void solve() {}
void debug_print_matrix(int matrix[11][11], int M, int N) {
  printf("debug_print_matrix: \r\n");
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < N; j++) {
      printf("%d ", matrix[i][j]);
    }
    printf("\r\n");
  }
}
int init_set(int n) {
  int num;
  int ret = 0;
  int len = pow(2, n);
  for (int i = 0; i < len; i++) {
    num = pow(2, i);
  }
}
void add_c_row(int matrix[11][11], int p, int q, int c, int N) {
  for (int i = 0; i < N; i++) {
    matrix[q][i] = (matrix[q][i] + matrix[p][i] * c) % 2;
  }
}
void exchange_row(int matrix[11][11], int p, int q, int N) {
  int temp;
  for (int i = 0; i < N; i++) {
    temp = matrix[q][i];
    matrix[q][i] = matrix[p][i];
    matrix[p][i] = temp;
  }
}
void exchange_col(int matrix[11][11], int p, int q, int M) {
  int temp;
  for (int i = 0; i < M; i++) {
    temp = matrix[i][q];
    matrix[i][q] = matrix[i][p];
    matrix[i][p] = temp;
  }
}
int get_rank(int matrix[11][11], int M, int N, bool hom) {
  int ret = 0;
  int matrix_temp[11][11];
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < N; j++) {
      matrix_temp[i][j] = matrix[i][j];
    }
  }
  int pivot = 0;
  for (int i = 0; i < M && pivot < N; i++) {
    if (matrix_temp[pivot][i] == 0) {
      int ex = -1;
      for (int j = pivot; j < M; j++) {
        if (matrix_temp[j][i] != 0) {
          ex = j;
          break;
        }
      }
      if (ex == -1) {
        continue;
      }
      exchange_row(matrix_temp, pivot, ex, N);
    }
    for (int j = pivot + 1; j < M; j++) {
      if (matrix_temp[j][i] == 1) {
        add_c_row(matrix_temp, pivot, j, 1, N);
      }
    }
    ret++;
    pivot++;
  }
  return ret;
}
int main() {
  int N, M;
  int matrix[11][11] = {0};
  int p[11];
  int ret = -1;
  scanf("%d %d", &N, &M);
  int k;
  int s;
  for (int i = 0; i < M; i++) {
    scanf("%d", &k);
    for (int j = 0; j < k; j++) {
      scanf("%d", &s);
      matrix[i][s - 1] = 1;
    }
  }
  for (int i = 0; i < M; i++) {
    scanf("%d", &(matrix[i][N]));
  }
  int rank = get_rank(matrix, M, N, false);
  if (M > N) {
    int homo_rank = get_rank(matrix, M, N + 1, true);
    if (homo_rank != rank) {
      printf("0\r\n");
      return 0;
    }
  }
  int dimker = N - rank;
  ret = (dimker == 0) ? 1 : pow(2, dimker);
  printf("%d\r\n", ret);
  fflush(stdout);
  return 0;
}
