using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC128_C_Switches
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] nm = Console.ReadLine().Split(' ');
			int n = int.Parse(nm[0]);
			int m = int.Parse(nm[1]);
			int[] k = new int[m];
			List<int[]> switcheList = new List<int[]>();
			for(int i = 0; i < m; i++)
			{
				int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
				k[i] = input[0];
				int[] switches = new int[k[i]];
				for(int j = 0; j < k[i]; j++)
				{
					switches[j] = input[j + 1];
				}
				switcheList.Add(switches);
			}
			int[] p = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

			int ans = 0;
			for(int i = 0; i < Math.Pow(2, n); i++)
			{
				int lightCnt = 0;
				char[] status = Convert.ToString(i, 2).PadLeft(n, '0').ToCharArray();
				for(int j = 0; j < m; j++)
				{
					int onCnt = 0;
					foreach (int x in switcheList[j])
					{
						if(status[x - 1] == '1')
						{
							onCnt++;
						}
					}
					if(onCnt % 2 == p[m - 1])
					{
						lightCnt++;
					}
				}
				if(lightCnt == m)
				{
					ans++;
				}
			}

			Console.WriteLine(ans);
		}
	}
}
