using System;
using System.Linq;

namespace AtCoder {
	class Program {
		public static void Main() {
			int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = input[0]; int m = input[1];
			int[][] s = new int[m][];
			for (int i = 0; i < m; i++) {
				s[i] = Console.ReadLine().Split(' ').Select(int.Parse).Skip(1).ToArray();
			}
			int[] p = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			Console.WriteLine(Count(n, m, s, p, new bool[0]));

		}
		static int Count(int n, int m, int[][] s, int[] p, bool[] sw) {
			int result;
			if (sw.Length == n) {
				result = 0;
				int count = s.Where((x, i) => x.Where((_, j) => sw[j]).Count() % 2 == p[i]).Count();
				Console.WriteLine($"{string.Join(" ", sw)} : {count}");
				return count == m ? 1 : 0;
			}
			bool[] nsw = new bool[sw.Length + 1]; Array.Copy(sw, nsw, sw.Length);
			nsw[^1] = true;
			result = Count(n, m, s, p, nsw);
			nsw[^1] = false;
			result += Count(n, m, s, p, nsw);
			return result;
		}
	}
}
