#include<stdio.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int n,m,kk,ss,a[15][15],p[15],bm,ans,te;
inline bool alll(int x){
	fo(i,1,m){
		te=0;
		fo(j,0,n-1) if (x&(1<<j)) te+=a[j][i];
		if ((te&1)!=p[i]) return 0;
	}
	return 1;
}
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,m){
		scanf("%d",&kk);
		while (kk--){
			scanf("%d",&ss);
			a[ss-1][i]++;
		}
	}
	fo(i,1,m) scanf("%d",&p[i]);
	bm=(1<<n)-1;
	fo(i,0,bm) if (alll(i)) ans++;
	printf("%d\n",ans);
	return 0;
}