using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp87 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = st[0];
            int M = st[1];

            var k = new int[M];

            var s = new int[M][];
            for (int i = 0; i < M; i++) {
                var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                k[i] = x[0];
                s[i] = new int[k[i]];
                for (int j = 0; j < k[i]; j++) {
                    s[i][j] = x[j + 1] - 1;
                }
            }

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

            int ans = 0;
            int cnt = 0;

            for (int bit = 0; bit < (1 << N); bit++) {
                for (int lb = 0; lb < M; lb++) {
                    cnt = 0;
                    foreach(var element in s[lb]) {
                        if ((bit & (1 << element)) != 0) {
                            cnt++;
                        }
                    }

                    if (cnt % 2 == p[lb]) {
                        //OKなので何もせずスルーする
                    } else {
                        goto skip;
                    }
                }
                ans++;

                skip:;
            }

            Console.WriteLine(ans);
        }
    }
}
