local n,m=io.read("n","n")
local s={}
for i=1,m do
    local k=io.read("n")
    s[i]={}
    for j=1,k do
        s[i][j]=io.read("n")-1
    end
end
local p={}
for i=1,m do
    p[i]=io.read("n")
end

local counter=0
for bit=0,(1<<n)-1 do
    local checker=true
    for i=1,m do
        local onoff=0
        for _,v in pairs(s[i]) do
            onoff=onoff+(bit&(1<<v)>0 and 1 or 0)
        end
        if onoff%2~=p[i] then
            checker=false
        end
    end
    counter=counter+(checker and 1 or 0)
end
print(counter)