#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
using ll = long long;
using vll = vector<ll>;

int main(){
	//入力
	ll N,M; cin>>N>>M;
	vector<vector<ll>> s(M);
	rep(i,M){
		ll k; cin>>k;
		rep(j,k){
			ll a; cin>>a;a--;
			s[i].push_back(a);
		}
	}
	vll p(M); rep(i,M) cin>>p[i];
	
	ll ans=0;
	for(ll bit=0;bit<(1<<N);bit++){
		bool ok = true;
		rep(i,M){
			ll con=0;
			for (auto v : s[i]) {
                if (bit & (1<<v)) ++con;
            }
			if(con%2!=p[i]) ok=false;
		}
		if(ok)ans++;
	}
	
	//出力
	cout<<ans<<endl;
}
