using System;

namespace AtCoderABC128C
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]); //Switch
            int M = int.Parse(s[1]); //Lamp

            int[][] X = new int[M][]; //Lamp毎のSwitch
            bool[] sw = new bool[N];  //Swichのオンオフ

            for (int i = 0; i < M; i++)
            {
                s = Console.ReadLine().Split(' ');

                X[i] = new int[s.Length - 1];

                for (int j = 1; j < s.Length; j++)
                {
                    X[i][j - 1] = int.Parse(s[j]) -1;
                }
            }

            s = Console.ReadLine().Split(' ');
            int[] lt = new int[M];

            for (int i = 0; i < M; i++)
            {
                lt[i] = int.Parse(s[i]);
            }

            do
            {
                int count = 0;
                bool temp = true;

                for (int i = 0; i < M; i++)
                {
                    for (int j = 0; j < X[i].Length; j++)
                    {
                        if (sw[X[i][j]])
                            count++;
                    }

                    if (count % 2 != lt[i])
                    {
                        temp = false;
                        break;
                    }
                }

                if (temp)
                    ans++;

            } while ((sw = nextsw(sw)) != null);

            Console.WriteLine(ans.ToString());
        }

        static bool[] nextsw(bool[] sw)
        {
            for (int i = 0; i < sw.Length; i++)
            {
                if (!sw[i])
                {
                    sw[i] = true;
                    for (int j = 0; j < i; j++)
                    {
                        sw[j] = false;
                    }

                    return sw;
                }
            }

            return null;
        }
    }
}
