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

namespace agc030_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var text = Console.ReadLine();
            var list = text.Split(' ').ToList().Select(x => int.Parse(x)).ToList();

            var a = list[0];
            var b = list[1];

            var hogelist = new List<hoge>();
            for(int i = 0; i < b; i++){
                text = Console.ReadLine();
                list = text.Split(' ').ToList().Select(x => int.Parse(x)).ToList();

                var item = new hoge();

                item.a = list.Skip(1).ToList();

                hogelist.Add(item);
            }

            text = Console.ReadLine();
            list = text.Split(' ').ToList().Select(x => int.Parse(x)).ToList();

            for(int i = 0; i < list.Count; i++){
                hogelist[i].answer = list[i];
            }

            var pattern = Math.Pow(2, a);

            var sw = new List<int>();
            for(int i = 0; i < a; i++){
                sw.Add(0);
            }

            var allon = 0;
            for(int i = 0; i < pattern; i++){
                var bin = Convert.ToString(i, 2);
                var remain = a - bin.Length;
                if (remain > 0){
                    bin = new string('0', remain) + bin;
                } 

                for (int j = 0; j < a; j++){
                    var onoff = int.Parse(bin.Substring(j, 1));
                    sw[j] = onoff;
                }

                var isFind = false;
                foreach(var item in hogelist){
                    var total = 0;
                    foreach(var lampsw in item.a){
                        total = total + sw[lampsw];
                    }

                    var md = total % 2;

                    if (item.answer != md){
                        isFind = true;
                        break;

                    }

                }

                if (isFind == false){
                    allon++;
                }


            }

            Console.WriteLine(allon);
        }
    }

    class hoge{      
        public List<int> a;

        public int answer;
    }
}
