local Nsw, Nli = io.read("n", "n")
local switches = {}
local onconds = {}
for i=1,Nli do
    local k = io.read("n")
    local swi = {}
    switches[i] = swi
    for j=1,k do
        swi[j] = io.read("n")
    end
end
for i=1,Nli do
    onconds[i] = io.read("n")
end
-- Cartesian product
local function carprod(seqs)
    return coroutine.wrap(function()
        if #seqs == 0 then
            coroutine.yield({})
            return
        end
        local s1 = seqs[1]
        for _,v in ipairs(s1) do
            for t in carprod({select(2, table.unpack(seqs))}) do
                coroutine.yield({v, table.unpack(t)})
            end
        end
    end)
end

local zo = {0,1}
local set = {}
for i=1,Nsw do
    set[i] = zo
end
local ans = 0
for ss in carprod(set) do -- 1024 times
    --print(table.concat(ss, ""))
    local all_on = true
    for i=1,Nli do -- 10 times
        local swi = switches[i]
        local sum = 0
        for k,v in ipairs(swi) do -- 10 times
            if ss[v] == 1 then
                sum = sum + 1
            end
        end
        if sum % 2 == onconds[i] then
        else
            all_on = false
            break
        end
    end
    if all_on then
        ans = ans + 1
    end
end
print(ans)