#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<bool>> to(N);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
      int s;
      cin >> s;
      s--;
      to[i].push_back(s);
    }
  }
  vector<int> P(M);
  vector<int> Q(M);
  for (int i = 0; i < M; i++) {
    cin >> P[i];
  }
  int cnt = 0;
  for (int i = 0; i < (1 << N); i++) {
    for (int x = 0; x < M; x++) {
      Q[x] = 0;
    }
    bool flag = true;
    for (int j = 0; j < N; j++) {
      if (i >> j & 1) {
        for (int k = 0; k < to[j].size(); k++) {
          int q = to[j][k];
          Q[q]++;
          Q[q] = Q[q] % 2;
        }
      }
    }
    for (int l = 0; l < M; l++) {
      if (P[l] != Q[l]) {
        flag = false;
      }
    }
    if (flag) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
