#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n, m;
	cin >> n >> m;
	int k, in;
	bitset<11> bs[11];
	for (int i = 0; i < m; ++i)
	{
		cin >> k;
		for (int j = 0; j < k; ++j)
		{
			cin >> in;
			bs[i][in-1] = 1;
		}
	}
	int p[11];
	for (int i = 0; i < m; ++i)
	{
		cin >> p[i];
	}
	bitset<11> now, check;
	int ans = 0;
	for (int i = 0; i < (2<<(n-1)); ++i)
	{
		now = i;
		int ok = 1;
		for (int j = 0; j < m; ++j)
		{
			check = now & bs[j];
			if(check.count()%2!=p[j])
			{
				ok = 0;
			}
		}
		ans += ok;
	}
	cout << ans << endl;
	return 0;
}