#include <bits/stdc++.h>
char str[200002];
int N, M;
int k[101];
int s[101][11];
int p[101];
int flag[11];
void receive_input() {
  fgets(str, sizeof(str), stdin);
  sscanf(str, "%d %d", &N, &M);
  for (size_t i = 1; i <= M; i++) {
    scanf("%d", &k[i]);
    for (size_t j = 1; j <= k[i]; j++) {
      scanf("%d", &s[i][j]);
    }
  }
  for (size_t i = 1; i <= M; i++) {
    scanf("%d", &p[i]);
  }
}
int increment(int n) {
  if (n == N + 1) {
    return 0;
  }
  if (flag[n] == 0) {
    flag[n] = 1;
    return 1;
  } else {
    flag[n] = 0;
    return increment(n + 1);
  }
}
int is_all_light() {
  for (size_t i = 1; i <= M; i++) {
    int count = 0;
    for (size_t j = 1; j <= k[i]; j++) {
      if (flag[j]) {
        count++;
      }
    }
    if (count % 2 != p[i]) {
      return 0;
    }
  }
  return 1;
}
int solve() {
  int ans = 0;
  do {
    if (is_all_light()) {
      ans++;
    }
  } while (increment(1));
  return ans;
}
int main(void) {
  receive_input();
  printf("%d\n", solve());
  return 0;
}
