#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;
int main(){
	int N, M; cin >> N >> M;
	vector<ll> k(M), p(M);
	vector<vector<ll> > s(M);

	for(int i = 0; i < M; ++i){
		cin >> k[i];
		for(int j = 0; j < k[i]; ++j){
			int si; cin >> si;
			s[i].push_back(si);
		}
	}
	for(int i = 0; i < M; ++i) cin >> p[i];


	int allcnt = 0;
	for(int i = 0; i < pow(2, N); ++i){
		int flag = 1;
		for(int j = 0; j < M; ++j){
			int cnt = 0;
			for(int l = 0; l < s[j].size(); ++l){
				if((i & (1<<(s[j][l]-1))) == (1<<(s[j][l]-1))) cnt++;
			}
			if(cnt % 2 != p[j]) { flag = 0; break; }
		}
		if(flag) allcnt ++;
	}

	cout << allcnt << endl;

	return 0;
}
