#include<bits/stdc++.h>
using namespace std;
const int maxn = 300001;
int n, m, s[11][11], slen[11], p[11], ans;
int ok(int light){
	for(int i = 0;i < m;++i){
		int cnt = 0;
		for(int j = 0;j < slen[i];++j){
			cnt += (bool)(light & (1 << s[i][j]));
		}
		if(p[i] != (cnt & 1))return false;
	}
	return true;
}
int main(){
	cin >> n >> m;
	for(int i = 0;i < m;++i){
		cin >> slen[i];
		for(int j = 0;j < slen[i];++j){
			cin >> s[i][j];
			--s[i][j];
		}
	}
	for(int i = 0;i < m;++i)cin >> p[i];
	for(int light = 0;light < (1 << n);++light){
		ans += ok(light);
	}
	cout << ans << '\n';
}
