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

namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            var N_switch = cin.nextInt();
            var M_ramp = cin.nextInt();

            var switch_list = new List<int[]>();
            for (int i = 0; i< M_ramp; i++)
            {
                var k = cin.nextInt();
                int[] row = new int[k];
                for(int j = 0; j < k; j++)
                {
                    row[j] = cin.nextInt();
                }
                switch_list.Add(row);
            }
            int[] p = new int[M_ramp];
            for (int i = 0; i < M_ramp; i++)
            {
                p[i] = cin.nextInt();
            }
            //

            var ans = 0;
            for (int bit = 1; bit < (1 << N_switch); ++bit)
            {
                // スイッチオンオフの全探索 1024 
                var bitArray = Convert.ToString(bit, 2).PadLeft(N_switch, '0').ToArray();
                //このパターンが全部の電球を点灯させるか？
                var allOK = true;

                for(int i = 0; i < M_ramp; i++)
                {
                    // 各ランプについて 10 現在のパターンがこの電球を点灯させるか？

                    var thisRamp = p[i];

                    var hasSwitch = switch_list[i];
                    int temp = 0;
                    for (int j = 0; j < hasSwitch.Length; j++)
                    {
                        if (bitArray[hasSwitch[j]-1] == '1') temp++;
                    }
                    
                    if(!(temp %2 == thisRamp))
                    {
                        allOK = false;
                        break;
                    }
                }
                if (allOK) ans++;
            }

            Console.WriteLine(ans);
        }
    }
    
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
    public static class ListExtensions
    {

        public static T Dequeue<T>(this IList<T> self)
        {
            var result = self[0];
            self.RemoveAt(0);
            return result;
        }


        public static void Enqueue<T>(this IList<T> self, T item)
        {
            self.Add(item);
        }


        public static T Peek<T>(this IList<T> self)
        {
            return self[0];
        }
    }

}
