#include <iostream>

using namespace std;

int n, m, k[15], s[15][15], p[15], ans;

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		cin >> k[i];
		for (int j = 1; j <= k[i];j++)
		{
			cin >> s[i][j];
		}
	}
	for (int i = 1; i <= m; i++) cin >> p[i];
	for (int i = 0; i < (1<<(n)); i++)
	{
		bool fl = 1;
		for (int j = 1; j <= m; j++)
		{
			int cnt = 0;
			for (int a = 1; a <= k[j]; a++)
			{
				if ((1<<(s[j][a]-1)) & i) cnt++;
			}
			if (cnt % 2 != p[j]) {fl = 0; break;}
		}
		if (fl) ans++;
	}
	cout << ans << endl;
	return 0;
}