#include <bits/stdc++.h>
using namespace std;
int N, M;
int* k;
int** s;
int* p;
int check_all_lamp(int* state) {
  bool all_on = true;
  for (int i = 0; i < M; i++) {
    int sum = 0;
    for (int j = 0; j < k[i]; j++) {
      sum += state[s[i][j]];
    }
    if (sum % 2 != p[i]) all_on = false;
  }
  return all_on ? 1 : 0;
}
int dfs(int depth, int* state) {
  if (depth == N)
    return check_all_lamp(state);
  else {
    int* s0 = (int*)malloc(sizeof(int) * N);
    int* s1 = (int*)malloc(sizeof(int) * N);
    memcpy(s0, state, sizeof(int) * N);
    memcpy(s1, state, sizeof(int) * N);
    s0[depth + 1] = 0;
    s1[depth + 1] = 1;
    return dfs(depth + 1, s0) + dfs(depth + 1, s1);
  }
}
int main() {
  cin >> N >> M;
  k = (int*)malloc(sizeof(int) * M);
  s = (int**)malloc(sizeof(int*) * M);
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    s[i] = (int*)malloc(sizeof(int) * k[i]);
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  p = (int*)malloc(sizeof(int) * M);
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int* state = (int*)calloc(N, sizeof(int));
  int rlt = dfs(0, state);
  cout << rlt << endl;
  return 0;
}
