#include <bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define in(x) scanf("%d",&x)
#define out(x) printf("%d\n",x)
#define ll long long

int n,m,k[15],a[15][15],p[15],ans,flag,sum;
signed main(){
	in(n),in(m);
	FOR(i,1,m){
		in(k[i]);
		FOR(j,1,k[i]){
			in(a[i][j+1]);
		}
	}
	FOR(i,1,m)
	in(p[i]);
	ans=0;
	for(int i=0;i<(1<<n);i++){
		flag=0;
		for(int j=1;j<=m;j++){
			sum=0;
			for(int r=1;r<=k[j];r++){
				if((1<<(a[j][r+1]-1))&i){
					sum++;
				}
			}
			if(sum%2!=p[j]){			
				flag=1;
			}
		}
		if(!flag)ans++;
	}
	cout<<ans<<endl;
	return 0;
} 