#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M, res;
  cin >> N >> M;
  vector<vector<long long>> s(M);
  for (long long i = (0), iLen_ = (M); i < iLen_; i++) {
    long long K;
    cin >> K;
    for (long long j = (0), jLen_ = (K); j < jLen_; j++) {
      long long a;
      cin >> a;
      a--;
      s[i].push_back(a);
    }
  }
  vector<long long> p(M);
  for (long long i = (0), iLen_ = (M); i < iLen_; i++) {
    cin >> p[i];
  }
  res = 0;
  for (long long bit = 0; bit < (1 << N); ++bit) {
    bool isOK = true;
    for (long long i = (0), iLen_ = (M); i < iLen_; i++) {
      long long con = 0;
      for (auto v : s[i]) {
        if (bit & (1 << v)) ++con;
      }
      if (con % 2 == p[i]) isOK = false;
    }
    if (isOK) res++;
  }
  cout << res << endl;
}
