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

namespace Competitive
{
    internal class Solution
    {
        public int N, M;
        public int[,] P;
        private int[] A;
        public long MOD = 1000000007;
        long ret = 0;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                M = line[1];
            }

            P = new int[M, N];
            for (int m = 0; m < M; m++)
            {
                var line = Input.ReadIntArray();
                line = line.Skip(1).ToArray();
                for (int i = 0; i < line.Length; i++)
                {
                    int n = line[i];
                    P[m, n - 1] = 1;
                }
            }

            A = new int[M];
            {
                var line = Input.ReadIntArray();
                for (int m = 0; m < M; m++)
                {
                    A[m] = line[m];
                }
            }

            ret = 0;

            // ビット列の生成
            var bf = new BruteForceBit(N, Process);
            bf.DFSRun();

            // 終了処理
            Console.WriteLine(ret);
        }

        void Process(bool[] sws)
        {
            bool success = true;
            for (int m = 0; m < M; m++)
            {
                int c = 0;
                for (int n = 0; n < N; n++)
                {
                    if (sws[n] && P[m, n] == 1) c++;
                }

                if (c % 2 != A[m]) success = false;
            }

            if (success) ret++;
        }
    }

    // libs ----------
    // 0/1ビット列を全通り列挙
    class BruteForceBit
    {
        public int N;
        public bool[] F;
        private Action<bool[]> Process;

        public BruteForceBit(int N, Action<bool[]> process)
        {
            this.N = N;
            F = new bool[N];
            Process = process;
        }

        public void DFSRun()
        {
            DFS(0);
        }

        private void DFS(int i)
        {
            if (i == N)
            {
                Process(F);
            }
            else
            {
                F[i] = true;
                DFS(i + 1);
                F[i] = false;
                DFS(i + 1);
            }
        }

    }


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13396