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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> ss(m);
	vector<int> ps(m);
	for (auto &s : ss)
	{
		int k;
		cin >> k;
		for (int i = 0; i < k; i++)
		{
			int x;
			cin >> x;
			s.emplace_back(x - 1);
		}
	}
	for (auto &p : ps)
	{
		cin >> p;
	}

	int ans = 0;
	for (int i = 0; i < (1 << n); i++)
	{
		bool f = true;
		for (int j = 0; j < m; j++)
		{
			int cnt = 0;
			for (int x : ss[j])
			{
				if ((i >> x) & 1)
				{
					cnt++;
				}
			}
			f &= (cnt % 2) == ps[j];
		}
		if (f)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}