#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s;
  s.assign(M, vector<int>());
  for (int i = 0; i < M; ++i) {
    cin >> k.at(i);
    for (int j = 0; j < k.at(i); ++j) {
      int x;
      cin >> x;
      --x;
      s[i].push_back(x);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; ++i) {
    cin >> p.at(i);
  }
  vector<vector<int>> S;
  S.assign((1 << N), vector<int>());
  for (int i = 0; i < (1 << N); ++i) {
    for (int j = 0; j < N; ++j) {
      if (i & (1 << j)) {
        S[i].push_back(int(1 << j) - 1);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (1 << N); ++i) {
    int on_num = 0;
    for (int j = 0; j < M; ++j) {
      int sum = 0;
      for (int l = 0; l < k.at(j); ++l) {
        for (int m : S[i]) {
          if (s[j][l] == m) {
            ++sum;
          }
        }
      }
      if (sum % 2 == p[j]) {
        ++on_num;
      }
    }
    if (on_num == M) {
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
