parseint(x) = parse(Int, x)
parseintmap(x::Array{SubString{String},1}) = map(parseint, x)

function solve(n::Int, m::Int, d, eo)
    ret = 0
    for i in 0:2^n - 1
        on = 0
        for j in 1:m
            s = 0
            for switch in d[j]
                if (i >> (switch - 1) & 1) == 1
                    s += 1
                end
            end
            if (s % 2 == eo[m])
                on += 1
            end
        end
        if on == m
            ret += 1
        end
    end
    ret
end

function main()
    n, m = readline() |> split |> parseintmap
    d = Dict()
    for i in 1:m
        a = readline() |> split |> parseintmap
        d[i] = a[2:a[1]+1]
    end
    eo = readline() |> split |> parseintmap
    println(solve(n, m, d, eo))
end

main()