parseint(x) = parse(Int, x)
ints() = map(parseint, readline() |> split)

function main()
    n, m = ints()
    s = [ints()[2:end] for _ = 1:m]
    sset = [Set{Int}(s[i]) for i = 1:m]
    p = ints()
    cnt = 0
    for i = 0:(1<<n)-1
        set = Set{Int}()
        for bit = 0:n-1
            if 1<<bit & i != 0
                push!(set, bit + 1)
            end
        end
        c = 0
        b = true
        for j = 1:m
            for e in set
                if e in sset[j]
                    c = 1 - c
                end
            end
            if c != p[j]
                b = false
            end
        end
        if b
            cnt += 1
        end
    end
    println(cnt)
end

main()