using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{

    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);

            int maxSW = (int)Math.Pow(2, N);

            int[] count = new int[M];
            int[] mask = new int[M];

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

                int K = int.Parse(s[0]);

                for (int j = 0; j < K; j++)
                {
                    mask[i] |= (1 << (int.Parse(s[j + 1]) -1));
                }
            }

            s = Console.ReadLine().Split(' ');
            for (int i = 0; i < M; i++)
            {
                count[i] = int.Parse(s[i]);
            }

            int ans = 0;
            for (int i = 0; i < maxSW; i++)
            {
                bool isOn = true;
                for (int j = 0; j < M; j++)
                {
                    int r = i & mask[j];
                    if(count[j] != bitCount(r) % 2)
                    {
                        isOn = false;
                        break;
                    }
                }

                if (isOn)
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }


        static int[] bitC = new int[]
        {
            0,1,1,2,
            1,2,2,3,
            1,2,2,3,
            2,3,3,4
        };

        static int bitCount(int i)
        {
            int c = 0;
            while(i>0)
            {
                c += bitC[i & 0x0f];
                i >>= 8;
            }

            return c;
        }
    }
}
