#include <bits/stdc++.h>
#define MAXN 20
using namespace std;
int main(){
	int N,M;
	cin>>N>>M;
	int arr[MAXN][MAXN];
	for(int i = 0;i<M;i++){
		int k;
		cin>>k;
		arr[i][0] = k;
		for(int j =0;j<k;j++){
			int t;
			cin>>t;
			arr[i][j+1] = t;
		}
	}
	vector<int> parr;
	for(int i=0;i<M;i++){
		int t;
		// ciparr
		cin>>t;
		parr.push_back(t);
	}
	int stasum = 0;
	for(int sta = 0;sta<=(1<<N)-1;sta++){
		int flag = 1;
		//cerr<<"sta"<<endl;
		//cerr<<sta<<endl;
		for(int i=0;i<M;i++){
			int rd = arr[i][0];
			int sum= 0;
			for(int j=0;j<rd;j++){
				int check_b = arr[i][j+1];
				if(sta&(1<<(check_b-1))){
					//cerr<<"check bit"<<check_b<<" "
					;sum+=1;}
			}
			//cerr<<endl;
			if(sum%2 != parr[i]){//cerr<<"fail "<<i<<endl;flag = 0;break;}
		}
		if(flag)stasum++;
	}
	cout<<stasum<<endl;
	return 0;
}