using System;
using System.Collections.Generic;

namespace cswork
{

    class Program
    {
        public Program() { }

        Scanner cin;

        void Omame()
        {
            cin = new Scanner();

            int n = cin.nextInt();
            int m = cin.nextInt();

            List<int> sList = new List<int>();
            for (int i = 0; i < m; i++)
            {
                int k = cin.nextInt();
                int s = 0;
                for (int j = 0; j < k; j++)
                {
                    int tmpS = cin.nextInt() - 1;
                    s += 1 << tmpS;
                }
                sList.Add(s);
            }

            List<int> pList = new List<int>();
            for (int i = 0; i < m; i++)
            {
                int p = cin.nextInt();
                pList.Add(p);
            }

            int ans = 0;
            for (int i = 0; i < 1 << n; i++)
            {
                bool add = true;
                for (int j = 0; j < m; j++)
                {
                    int p = pList[j];
                    int onSwitch = sList[j] & i;
                    int count = 0;
                    for (int k = 0; k < m; k++)
                    {
                        if ((1 << k & onSwitch) == 1 << k)
                        {
                            count++;
                        }
                    }

                    if (count % 2 != p)
                    {
                        add = false;
                        break;
                    }
                }

                if (add) ans++;
            }

            Console.WriteLine(ans);
        }

        static void Main(string[] args)
        {
            new Program().Omame();
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();

            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next();
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }
    }
}