#include <bits/stdc++.H>
using namespace std;

bool are_switched(bitset<10> bit, 
		const vector<bitset<10>> &l_switch, int M, const vector<int> &p)
{
	int	mod;
	for (int j = 0; j < M; ++j) {
		mod = (bit & l_switch.at(j)).count() % 2; 
		if (mod != p.at(j))
			return false;
	}
	return true;
}

int	main()
{
	int	N, M;
	cin >> N >> M;
	vector<bitset<10>> light_switch(M);
	for (int i = 0; i < M; ++i) {
		int	k;
		cin >> k;;
		int	s;
		for (int j = 0; j < k; ++j) {
			cin >> s;
			light_switch.at(i).set(s - 1);
		}
	}
	vector<int> p(M);
	for (int i = 0; i < M; ++i)
		cin >> p.at(i);
	int	cnt = 0;
	for (int i = 0; i < (1 << N); ++i) {
		bitset<10> bit(i);
		if (are_switched(bit, light_switch, M, p))
			++cnt;
	}
	cout << cnt << endl;
}
