//Bit full search.
#include<iostream>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef vector<int>   vi;
typedef vector<vi >   vvi;

int main(){
	int n,m;
	cin>>n>>m;
	
	vvi v(m);
	REP(i,m){
		int k;
		cin>>k;
		v[i].resize(k);
		REP(j,k){
			cin>>v[i][j];
			v[i][j]--;
		}
	}
	
	vi p(m);
	REP(i,m) cin>>p[i];
	
	int ans=0;
	REP(i,(1<<n)){//スイッチの付き方を全探索.
		bool jud=true;
		REP(j,m){//全ての電球を試す.
			int cnt=0;
			for(auto &elem:v[j]){
				if((i>>elem)&1) cnt++;
			}
			if(cnt%2!=p[j]){
				jud=false;
				break;
			}
		}
		if(jud) ans++;
	}
	
	cout<<ans<<endl;
}
