#include <bits/stdc++.h>
using namespace std;
using LLI = long long int;
int main(void) {
  int N, M, K, a, cnt = 0, res = 0;
  bool b = false;
  cin >> N >> M;
  vector<vector<int>> vec(M);
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> K;
    for (int j = 0; j < K; j++) {
      cin >> a;
      vec[i].push_back(a);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  vector<int> flag;
  for (int bit = 0; bit < (1 << N); ++bit) {
    for (int i = 0; i < N; i++) {
      if (bit & (1 << i)) {
        flag.push_back(i + 1);
      }
    }
    b = true;
    for (int i = 0; i < M; i++) {
      for (int id : vec[i]) {
        for (int j = 0; j < flag.size(); j++) {
          if (id == flag[j]) {
            cnt++;
          }
        }
      }
      if (cnt % 2 != p[i]) {
        b = false;
      }
    }
    if (b) {
      res++;
    }
    b = false;
    flag.clear();
  }
  cout << res << endl;
}
