#include <bits/stdc++.h>
using namespace std;
int N, M, cnt = 0;
int to[15][15];
int P[15];
bool socket[15];
void count() {
  int count[15];
  for (int i = 1; i <= M; i++) {
    for (int j = 1; j <= N; j++) {
      if (to[i][j] > 0 && socket[j] == true) {
        count[i]++;
      }
    }
  }
  bool flag = true;
  for (int i = 1; i <= M; i++) {
    if (count[i] % 2 != P[i]) {
      flag = false;
    }
  }
  if (flag) {
    cnt++;
  }
}
void dfs(int X) {
  if (X == N + 1) {
    count();
  }
  socket[X] = false;
  dfs(X + 1);
  socket[X] = true;
  dfs(X + 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 d;
      cin >> d;
      to[i][d]++;
    }
  }
  for (int i = 1; i <= M; i++) {
    cin >> P[i];
  }
  dfs(1);
  cout << cnt << endl;
  return 0;
}
