n, m = gets.strip.split(" ").map(&:to_i)

ks = []
m.times do
  t = gets.strip.split(" ").map(&:to_i)
  t.shift
  ks << t
end

p = gets.strip.split(" ").map(&:to_i)

ans = 0
0.upto(2**n - 1) do |s|
  ok = true
  ks.each.with_index do |ks2, i|
    o = 0
    ks2.each do |t|
      o += 1 if s[t - 1] == 1
    end

    if (o % 2) != p[i]
      ok = false
      break
    end

    break unless ok
  end

  ans += 1 if ok
end

puts ans
