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

#define INF_LL (int64_t)1e18
#define INF (int32_t)1e9

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main() {
  int N, M;
  cin >> N >> M;

  vector<vector<int>> s(M);
  vector<int> p(M);

  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    s[i].resize(k);
    for (auto&& e : s[i]) {
      cin >> e;
      e--;
    }
  }
  for (auto&& e : p) cin >> e;

  int res = 0;
  for (int sw = 0; sw < (1 << N); sw++) {
    int on = 0;
    for (int i = 0; i < M; i++) {
      int cnt = 0;
      for (int j = 0; j < s[i].size(); j++) {
        cnt += (sw >> s[i][j] & 1);
      }
      on += (cnt % 2 == p[i]);
    }
    res += (on == N);
  }
  cout << res << endl;
}
