local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max
local ior = io.input()
local n, m = ior:read("*n", "*n")
local k = {}
local p = {}
for i = 1, m do
  k[i] = {}
  local knum = ior:read("*n")
  for j = 1, knum do
    k[i][j] = ior:read("*n")
  end
end
for i = 1, m do p[i] = ior:read("*n") end
local allcnt = 2^n
local succeed = 0

local function check(comb)
  local stat = true
  for i_m = 1, m do
    local tmp = 0
    for i_k = 1, #k[i_m] do
      tmp = tmp + comb[k[i_m][i_k]]
    end
    if tmp % 2 ~= p[i_m] then
      return false
    end
  end
  return true
end

for ti = 0, allcnt - 1 do
  local comb = {}
  local i = ti
  for j = 1, n do
    comb[j] = i % 2
    i = mfl(i / 2)
  end
  if check(comb) then
    succeed = succeed + 1
  end
end
print(succeed)
