#include <iostream>
#include <vector>

using namespace std;

int N,M;
vector<int> s[15];
int p[15];
int ans;

inline bool judge(int state)
{
	int cnt=0;
	for (int i=1; i<=M; i++)
	{
		int tmp=0;
		for (int j=0; j<s[i].size(); j++) if (state>>(N-s[i][j])&1) tmp++;
		if (tmp%2==p[i]) cnt++;
	}
	return cnt==M;
}

int main()
{
	cin >> N >> M;
	for (int i=1; i<=M; i++)
	{
		int k;
		for (cin >> k; k--; )
		{
			int tmp;
			cin >> tmp;
			s[i].push_back(tmp);
		}
	}
	for (int i=1; i<=M; i++) cin >> p[i];
	for (int i=0; i<(1<<N); i++) if (judge(i)) ans++;
	cout << ans;
	return 0;
}