using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int[] NM = ReadLineParseIntArray();
        int N = NM[0];
        int M = NM[1];
        int[][] s = new int[M][];

        for(int i = 0; i < M; i++)
            s[i] = ReadLine().Split(' ').Skip(1).Select(int.Parse).ToArray();

        int[] p = ReadLineParseIntArray();
        int n = (int)Pow(2, N);
        int ans = 0;
        for(int i = 0; i <= n; i++)
        {
            bool isOK = true;
            for (int m = 0; m < M; m++)
            {
                int number = 0;
                for (int j = 0; j < s[m].Length; j++)
                {
                    if (((i >> j) & 1) == 1)
                        number++;
                }
                if (number % 2 != p[m])
                {
                    isOK = false;
                    break;
                }
            }
            if (isOK) ans++;
        }
        WriteLine(ans);
    }

    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}