local n, m = io.read("*n", "*n")
local t = {}
for i = 1, m do
  z = io.read("*n")
  t[i] = {}
  for j = 1, z do
    table.insert(t[i], io.read("*n"))
  end
end
local p = {}
for i = 1, m do
  p[i] = io.read("*n")
end
local ret = 0
local tot = 1
for i = 1, n do tot = tot * 2 end
local use = {}
for i = 0, tot - 1 do
  local ti = i
  for j = 1, n do
    use[j] = ti % 2
    ti = ti // 2
  end
  local v = true
  for j = 1, m do
    local q = 0
    for k = 1, #t[j] do
      q = q + use[t[j][k]]
    end
    if q % 2 ~= p[j] then v = false break end
  end
  if v then ret = ret + 1 end
end
print(ret)
