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

class Program
{
    static void Main()
    {
        var line1 = MyUtil.ReadlongArray();
        List<long>[] denkyu = new List<long>[line1[1]];

        for (int i = 0; i < line1[1]; i++)
        {
            var input = MyUtil.ReadlongArray().ToList();
            input.RemoveAt(0);
            denkyu[i] = input;
        }

        var target = MyUtil.ReadlongArray();

        int bit = 0;
        int res = 0;

        while (true)
        {
            bit++;
            if (bit.GetBit((int)line1[0] + 1) == 1)
            {
                break;
            }

            int ok = 0;

            for (int i = 0; i < denkyu.Length; i++)
            {
                var count = denkyu[i].Count(sw => bit.GetBit((int)sw) == 1);
                if (count % 2 == target[i])
                {
                    ++ok;
                }
            }

            if (ok == line1[1])
            {
                res++;
            }
        }

        WriteLine(res);

        ReadKey();
    }
}


static class MyUtil
{
    public static int GetBit(this int num, int count)
    {
        int mask = (int)Math.Pow(2, count - 1);
        return (num & mask) == 0 ? 0 : 1;
    }

    public static int[] ToBit(this int num)
    {
        const int size = sizeof(int) * 8;
        var array = new int[size];
        for (int i = 0; i < size; i++)
        {
            array[i] = num.GetBit(size - i);
        }
        return array;
    }

    public static long[] ReadlongArray()
    {
        return ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
    }

    /// <summary>
    /// <see cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="ts"></param>
    public static void WriteToConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append("\n");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        Console.WriteLine(stringBuilder.ToString());
    }
}
