using System;
using System.Collections.Generic;
using static AtCoderer.Exter;
using static System.Math;
using System.Linq;

namespace AtCoderer
{

    public class App
    {
        public static void Solve()
        {
            int n = Cini, m = Cini;
            int[][] s = new int[m][];
            int[] p = new int[m];
            for (int i = 0;i<m;i++)
            {
                var q = Cini;
                s[i] = new int[q];
                for (int j = 0; j < q; j++)
                {
                    s[i][j] = Cini-1;
                }
            }

            for (int i = 0; i < m; i++)
            {
                p[i] = Cini;
            }
            var e = new EnumAll(2,n);
            var c = 0;
            while (e.Next())
            {
                bool f = true;
                for (int i = 0; i < m; i++)
                {
                    var sum = 0;
                    foreach (int v in s[i])
                        sum += e.Current[v];
                    if (sum % 2 != p[i])
                        f = false;
                }
                if(f)
                    c++;
            }
            Console.WriteLine(c);
        }
        public static void Main(string[] args)
        {
            Solve();
            Console.ReadKey();
        }
    }
    public static class Exter
    {
        public static void rep(int loop, Action<int> act)
        {
            for (int i = 0; i < loop; i++)
                act(i);
        }
        public static int Max(params int[] p) => p.Max();
        public static long Max(params long[] p) => p.Max();
        public static int Min(params int[] p) => p.Min();
        public static long Min(params long[] p) => p.Min();
        public static int Gcd(int a, int b)=>a > b ? GcdRecursive(a, b) : GcdRecursive(b, a);
        private static int GcdRecursive(int x, int y) => y == 0 ? x : GcdRecursive(y, x % y);
        public static string ToString(this IEnumerable<char> v)
        {
            return string.Join("", v);
        }
        public static string Join<T>(this IEnumerable<T> v,char c)
        {
            return string.Join(c.ToString(), v);
        }
        public static string Join<T>(this IEnumerable<T> v, string s)
        {
            return string.Join(s, v);
        }
        public static int[] ReadArr
        {
            get
            {
                return Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            }
        }
        public static int Cini
        {
            get
            {
                string s = "";
                char c;
                do
                {
                    c = (char)Console.Read();
                    s += c;
                } while (char.IsWhiteSpace(c));
                return int.Parse(s);
            }
        }
        public static string Cins
        {
            get
            {
                string s = "";
                char c;
                do
                {
                    c = (char)Console.Read();
                    s += c;
                } while (char.IsWhiteSpace(c));
                return s;
            }
        }
        public static long Cinl
        {
            get
            {
                string s = "";
                char c;
                do
                {
                    c = (char)Console.Read();
                    s += c;
                } while (char.IsWhiteSpace(c));
                return long.Parse(s);
            }
        }
        public class EnumAll
        {
            bool Over = false;
            int UpperValue;
            int Dimension;
            public int[] Current { private set; get; }
            public EnumAll(int Value,int Dimension)
            {
                this.Dimension = Dimension;
                UpperValue = Value;
                Current = new int[Dimension];
                Current[0] = -1;
            }
            public bool Next()
            {
                if (Over)
                    return false;
                bool flag = false;
                for(int i = 0;i<Dimension;i++)
                {
                    if (++Current[i] >= UpperValue)
                        Current[i] = 0;
                    else
                    {
                        flag = true;
                        break;
                    }
                }
                if(!flag)
                {
                    Over = true;
                    return false;
                }
                return true;
            }
            public bool IsOver()
            {
                return Over;
            }
        }
        public class UnionFind
        {
            private int[] Parent;
            private int GetRoot(int v)
            {
                if (Parent[v] < 0)
                    return v;
                else
                    return Parent[v] = GetRoot(Parent[v]);
            }
            public UnionFind(int size)
            {
                Parent = new int[size];
                for (int i = 0; i < size; i++)
                    Parent[i] = -1;
            }
            public bool AreGrouped(int a, int b)
            {
                return GetRoot(a) == GetRoot(b);
            }
            public void Connect(int a, int b)
            {
                a = GetRoot(a);
                b = GetRoot(b);
                if (a == b) return;
                if (Parent[b] < Parent[a])
                {
                    Parent[b] += Parent[a];
                    Parent[a] = b;
                }
                else
                {
                    Parent[a] += Parent[b];
                    Parent[b] = a;
                }
            }
            public int GetGroupSize(int a)
            {
                return -Parent[GetRoot(a)];
            }
        }
    }
}
