#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(M);
  for (int i = 0, k; i < M; i++) {
    cin >> k;
    for (int j = 0, s; j < k && cin >> s; j++) S.at(i).push_back(--s);
  }
  vector<int> P(M);
  for (int &p : P) cin >> p;

  int ans = 0;
  for (int bit = 0; bit < 1 << N; bit++) {
    for (int i = 0; i < M; i++) {
      int cnt = 0;
      for (int s : S.at(i)) if (bit >> s & 1) cnt++;
      if (cnt % 2 != P.at(i)) goto NG;
    }
    ans++;
    NG:;
  }

  cout << ans << "\n";
}