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

namespace AtCorder
{
    class Program
    {

        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();
            var n = s[0];
            var m = s[1];
            var list = new List<int[]>();
            for (var i = 1; i <= m; i++)
            {
                s = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();
                list.Add(s);
            }
            var ps = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

            int result = 0;
            for (var i = 1; i < Math.Pow(2, n); i++)
            {
                var b = Convert.ToString(i, 2).PadLeft(10, '0').ToArray();
                var idx = 0;
                foreach (var x in list)
                {
                    int cnt = 0;
                    int ons = 0;
                    foreach (var y in x)
                    {
                        if (cnt == 0)
                        {
                            cnt++;
                            continue;
                        }

                        ons += b[y - 1];
                        cnt++;
                    }
                    if (ons % 2 != ps[idx])
                        break;
                    if (idx == list.Count - 1)
                    {
                        result++;
                    }

                }

            }

            Console.WriteLine(result.ToString());

        }
    }
}
