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

class Program
{
    public static cp alg;
    public static int[] P;
    public static int[][] KS;
    public static int N;
    public static int M;
    public static double num = 0;
    static void Main(string[] args)
    {
        alg = new cp();

        var temp = alg.inputSplitInt();
        N = temp[0];
        M = temp[1];
        KS = alg.inputJaggedArrayInt(M);
        P = alg.inputSplitInt();
        int kumi = 0;
        for (int a = 0; a<(1<<N); a++)
        {
            var use = new List<int>();
            for (int b = 0; b <N; b++)
            {
                if ((a & (1 << b)) > 0)
                {
                    use.Insert(0,1);
                }
                else
                {
                    use.Insert(0,0);
                }
            }
            int lcount = 0;
            for (int b = 0; b < M; b++)
            {
                int scount = 0;
                for (int c = 0; c < KS[b][0]; c++)
                {
                    int index = KS[b][c + 1] - 1;
                    if (use[index] == 1)
                    {
                        scount++;
                    }
                }
                if ((double)scount%2.0==P[b])
                {
                    lcount++;
                }
            }
            if (lcount==M)
            {
                kumi++;
            }
        }
        WriteLine(kumi);
    }
}

class cp
{

    public cp()
    {
    }
    public int GCD(int a, int b)
    {
        return a % b == 0 ? b : GCD(b, a % b);
    }
    public int LCM(int a, int b)
    {
        return a * b / GCD(a, b);
    }
    public int countChar(string s, string key)
    {
        return (s.Length - s.Replace(key, "").Length);
    }
    public string Yn(bool f)
    {
        if (f)
        {
            return "Yes";
        }
        else
        {
            return "No";
        }
    }
    public string YN(bool f)
    {
        if (f)
        {
            return "YES";
        }
        else
        {
            return "NO";
        }
    }
    public string yn(bool f)
    {
        if (f)
        {
            return "yes";
        }
        else
        {
            return "no";
        }
    }
    public void inputSkip()
    {
        ReadLine();
        return;
    }
    public string inputString()
    {
        return ReadLine();
    }
    public string[] inputSplitString()
    {
        return ReadLine().Split();
    }
    public string[] inputLinesString(int len)
    {
        var arr = new string[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine();
        }
        return arr;
    }
    public string[][] inputJaggedArrayString(int len)
    {
        var arr = new string[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split();
        }
        return arr;
    }
    public int inputInt()
    {
        return int.Parse(ReadLine());
    }
    public int[] inputSplitInt()
    {
        return ReadLine().Split().Select(i => int.Parse(i)).ToArray();
    }
    public int[] inputLinesInt(int len)
    {
        var arr = new int[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = int.Parse(ReadLine());
        }
        return arr;
    }
    public int[][] inputJaggedArrayInt(int len)
    {
        var arr = new int[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        }
        return arr;
    }
    public long inputLong()
    {
        return long.Parse(ReadLine());
    }
    public long[] inputSplitLong()
    {
        return ReadLine().Split().Select(i => long.Parse(i)).ToArray();
    }
    public long[] inputLinesLong(long len)
    {
        var arr = new long[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = long.Parse(ReadLine());
        }
        return arr;
    }
    public long[][] inputJaggedArrayLong(int len)
    {
        var arr = new long[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split().Select(i => long.Parse(i)).ToArray();
        }
        return arr;
    }
    public double inputDouble()
    {
        return double.Parse(ReadLine());
    }
    public double[] inputSplitDouble()
    {
        return ReadLine().Split().Select(i => double.Parse(i)).ToArray();
    }
    public double[] inputLinesDouble(int len)
    {
        var arr = new double[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = double.Parse(ReadLine());
        }
        return arr;
    }
    public double[][] inputJaggedArrayDouble(int len)
    {
        var arr = new double[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split().Select(i => double.Parse(i)).ToArray();
        }
        return arr;
    }
}

Measured memory_bytes: 13396