#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<string.h>
#include<iostream>
using namespace std;
struct node {
	int k[11] = { 0 }, p,nu;
}bu[11];
int main()
{
	int n, m, ans = 0;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++)
	{
		scanf("%d", &bu[i].nu);
		for (int j = 1; j <= bu[i].nu; j++)
		{
			scanf("%d", &bu[i].k[j]);
		}
	}
	for (int i = 1; i <= m; i++)
		scanf_s("%d", &bu[i].p);
	for (int i = 0; i < (1 << n); i++)
	{
		int sum2 = 0;
		for (int j = 1; j <= m; j++)
		{
			int sum = 0;
			for (int d = 1;d<=bu[j].nu; d++)
				if (((1 << (bu[j].k[d]-1))&i) > 0)
					sum++;
			if (sum%2 == bu[j].p)
				sum2++;
		}
		if (sum2 == m)
			ans++;
	}
	printf("%d", ans);
	//system("pause");
	return 0;
}