#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<int> p;
vector<vector<int>> den;
int res;
int DFS(int i, int bo, vector<int> list) {
  int count;
  int count2;
  int temp;
  int temp2;
  list[M + 1];
  if (i == 0) {
    if (bo) {
      list[0] = 1;
    } else {
      list[0] = 0;
    }
  }
  if (i == M) {
    for (int j = 0; j < M; j++) {
      for (int o = 0; o < N; o++) {
        temp = den[j][o];
        temp2 = list[temp];
        if (temp2 == 1) count += 1;
      }
      if (count % 2 == p[j]) count2 += 1;
    }
    if (count2 == M) return res += 1;
    return res += 0;
  }
  list[i] = bo;
  DFS(i + 1, 0, list);
  DFS(i + 1, 1, list);
  return res;
}
int main() {
  vector<int> list;
  cin >> N >> M;
  int kk;
  for (int k = 0; k < M; k++) {
    cin >> kk;
    for (int n = 0; n < N; n++) {
      den[k][n] = 2;
    }
    for (int l = 0; l < kk; kk++) {
      cin >> den[k][l];
    }
  }
  for (int k = 0; k < M; k++) cin >> p[k];
  DFS(0, 0, list);
  DFS(0, 1, list);
  cout << res << endl;
}
