#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<long long>;
using P = pair<long long, long long>;
using T = tuple<long long, long long, long long>;
using ll = long long;
long long charToInt(char c) {
  char zero_num = '0';
  return (long long)c - (long long)zero_num;
}
signed main() {
  long long N, M;
  cin >> N >> M;
  vec_int k(M);
  vector<vector<long long>> s(M);
  for (long long i = 0; i < (long long)(M); i++) {
    cin >> k.at(i);
    vec_int temp(k.at(i));
    for (long long j = 0; j < (long long)(k.at(i)); j++) cin >> temp.at(j);
    s.at(i) = temp;
  }
  vec_int p(M);
  for (long long i = 0; i < (long long)(M); i++) {
    cin >> p.at(i);
  }
  long long tott = 0;
  for (long long combi = 0; combi < pow(2, N); combi++) {
    bitset<10> bits(combi);
    long long num = 0;
    for (long long i = 0; i < M; i++) {
      vec_int light_arr = s.at(i);
      vec_int switch_state(N, 0);
      long long tot_on = 0;
      for (long long j = 0; j < N; j++) {
        for (auto aaa : light_arr) {
          if (aaa == j) {
            tot_on++;
            break;
          }
        }
      }
      if (tot_on % 2 == p.at(i)) {
        num++;
      }
    }
    if (num == M) {
      tott++;
    }
  }
  cout << tott << endl;
  return 0;
}
