#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m; cin >> n >> m;
	vector<int> p(m);
	vector<vector<int> > vals;
	for(int i = 0; i < m; i++){
		int k; cin >> k;
		vector<int> now;
		for(int j = 0; j < k; j++){
			int x; cin >> x; x--;
			now.push_back(x);
		}
		vals.push_back(now);
	}
	for(int i = 0; i < m; i++) cin >> p[i];
	int ans = 0;
	for(int i = 0; i < 1<<n; i++){
		bool ok = true;
		for(int j = 0; j < m; j++){
			int val = 0;
			for(int k : vals[j]) val += (i>>k)&1;
			val %= 2;
			ok &= val == p[j];
		}
		ans += ok;
	}
	cout << ans << endl;
	return 0;
}
