using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

            var s = new int[M][];
            var p = new int[M];

            for (int i = 0; i < M; i++)
            {
                var inputsw = Console.ReadLine().Split(' ');
                var k = int.Parse(inputsw[0]);
                s[i] = new int[k];
                for (int j = 1; j <= k; j++)
                {
                    s[i][j - 1] = int.Parse(inputsw[j]) - 1;
                }
            }
            var inputp = Console.ReadLine().Split(' ');
            for (int i = 0; i < M; i++)
            {
                p[i] = int.Parse(inputp[i]);
            }

            var ans = 0;
            for (int bit = 0; bit < (1 << N); bit++)
            {
                var ok = true;
                for (int i = 0; i < M; i++)
                {
                    var c = 0;
                    foreach (var item in s[i])
                    {
                        if ((bit >> item & 1) != 0)
                        {
                            c++;
                        }
                    }

                    c %= 2;
                    if (c != p[i])
                    {
                        ok = false;
                    }
                }
                if (ok)
                {
                    ans++;
                }
            }
        }
    }
}