#include <bits/stdc++.h>
using namespace std;
int to[12][12];
int p[12];
bool switch1[12];
int connect[12];
int cnt = 0;
int N, M;
void count() {
  for (int i = 1; i <= M; i++) {
    connect[i] = 0;
  }
  for (int i = 1; i <= M; i++) {
    for (int X = 1; X <= N; X++) {
      if (to[i][X] > 0 && switch1[X] == true) {
        connect[i]++;
      }
    }
  }
  bool flag = true;
  for (int j = 1; j <= M; j++) {
    if (connect[j] % 2 != p[j]) {
      flag = false;
    }
  }
  if (flag) {
    cnt++;
  }
}
void dfs(int depth) {
  if (depth == N + 1) {
    count();
    return;
  }
  switch1[depth] = true;
  dfs(depth + 1);
  switch1[depth] = false;
  dfs(depth + 1);
}
int main() {
  cin >> N >> M;
  for (int i = 1; i <= M; i++) {
    int c;
    cin >> c;
    for (int j = 1; j <= c; j++) {
      int s;
      cin >> s;
      to[i][s]++;
    }
  }
  for (int i = 1; i <= M; i++) {
    cin >> p[i];
  }
  cout << cnt << endl;
  return 0;
}
