// A Dynamic Programming based 
// C# program to find minimum 
// number operations to 
// convert str1 to str2 
using System;
using System.Collections.Generic;
using System.Linq;

class Restr
{
    public int Id;
    public String Name;
    public int Score;
}

class GFG
{

    public static void Main()
    {
        var input = Console.ReadLine().Split(' ');

        var n = int.Parse(input[0]);
        var m = int.Parse(input[1]);

        List<int>[] swiitch = new List<int>[m];

        for (int i = 0; i < m; i++)
        {
            swiitch[i] = new List<int>();
            var input2 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            for (int j = 0; j < input2[0]; j++)
            {
                swiitch[i].Add(input2[j + 1]-1);
            }
        }

        var p = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int ans = 0;
        for (int i = 1; i < (1 << n); i++)
        {
            bool bulbLight = true;

            for (int d = 0; d < m; d++)
            {
                int cont = 0;
                foreach (var j in swiitch[d])
                {
                    if (((1 << j) & i) != 0)
                    {
                        cont++;
                    }
                }
                if (cont % 2 != p[d])
                {
                    bulbLight = false;
                    break;
                }
            }

            if (bulbLight)
            {
                ans++;
            }


        }
        Console.Write(ans);

    }
}
