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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2 2");
            WillReturn.Add("2 1 2");
            WillReturn.Add("1 2");
            WillReturn.Add("0 1");
            //1
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2 2");
            WillReturn.Add("2 1 2");
            WillReturn.Add("1 1");
            WillReturn.Add("1 2");
            WillReturn.Add("0 0 1");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("5 2");
            WillReturn.Add("3 1 2 5");
            WillReturn.Add("2 2 3");
            WillReturn.Add("1 0");
            //8
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int N = wkArr[0];
        int M = wkArr[1];

        var KArrList = new List<int[]>();
        foreach (string EachStr in InputList.Skip(1).Take(M)) {
            KArrList.Add(EachStr.Split(' ').Select(X => int.Parse(X)).ToArray());
        }
        int[] PArr = InputList[M + 1].Split(' ').Select(X => int.Parse(X)).ToArray();

        int Answer = 0;
        foreach (bool[] EachOnOffArr in DeriveOnOffArrList(N)) {
            //Array.ForEach(EachOnOffArr, (pX) => Console.Write(pX));
            //Console.WriteLine();

            bool IsAnswer = true;
            for (int I = 0; I <= KArrList.Count - 1; I++) {
                int SumCnt = 0;
                foreach (int EachInd in KArrList[I]) {
                    if (EachOnOffArr[EachInd - 1]) SumCnt++;
                }
                if (SumCnt % 2 != PArr[I]) {
                    IsAnswer = false;
                }
            }
            if (IsAnswer) Answer++;
        }
        Console.WriteLine(Answer);
    }

    struct JyoutaiDef
    {
        internal int CurrInd;
        internal bool[] OnOffArr;
    }

    //Nを引数として、OnOffの配列のListを返す
    static List<bool[]> DeriveOnOffArrList(int pN)
    {
        int UB = pN - 1;

        var Stk = new Stack<JyoutaiDef>();

        JyoutaiDef WillPush;
        WillPush.CurrInd = 0;
        WillPush.OnOffArr = new bool[UB + 1];
        Stk.Push(WillPush);

        var WillReturn = new List<bool[]>();
        while (Stk.Count > 0) {
            JyoutaiDef Popped = Stk.Pop();

            if (Popped.CurrInd > UB) {
                WillReturn.Add(Popped.OnOffArr);
                continue;
            }

            WillPush.CurrInd = Popped.CurrInd + 1;

            WillPush.OnOffArr = (bool[])Popped.OnOffArr.Clone();
            WillPush.OnOffArr[Popped.CurrInd] = false;
            Stk.Push(WillPush);

            WillPush.OnOffArr = (bool[])Popped.OnOffArr.Clone();
            WillPush.OnOffArr[Popped.CurrInd] = true;
            Stk.Push(WillPush);
        }

        return WillReturn;
    }
}
