using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC128
{
	class Program
	{
		static void Main(string[] args)
		{
			var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
			var (N, M) = (nm[0], nm[1]);
			var skm = ReadLines(M)
					.Select(x => x.Split(' ').Skip(1).Select(int.Parse).Select(i => i - 1))
					.Select((x, i) => new { k = i, s = x })
					.SelectMany(x => x.s.Select(s => new { s, k = x.k }))
					.GroupBy(x => x.s, x => x.k)
					.ToList();
			var pm = Convert.ToInt32(new string(Console.ReadLine().Replace(" ", "")), 2);

			var ans = 0;
			foreach (var i in Enumerable.Range(0, (int)Math.Pow(2, N)))
			{
				var sw = Convert.ToString(i, 2).Reverse();
				var rp = new int[M];

				foreach (var (c, s) in sw.Select((x, j) => (c: x, s: j)).Where(x => x.c == '1'))
				{
					var sk = skm.FirstOrDefault(x => x.Key == s);
					if (sk == null) continue;
					foreach (var k in sk)
					{
						rp[k]++;
					}
				}

				var rpi = Convert.ToInt32(string.Join("", rp.Select(x => x % 2)), 2);
				if (rpi == pm) ans++;
			}
			Console.WriteLine(ans);
		}

		static IEnumerable<string> ReadLines(int n)
		{
			foreach (var _ in Enumerable.Range(0, n)) yield return Console.ReadLine();
		}
	}
}
