N, M = gets.split.map(&:to_i)
ks_list = M.times.map { gets.split.map(&:to_i) }
s_list = ks_list.map.with_index { |(k, *ary), i| [i, ary] }
p_list = gets.split.map(&:to_i)

count = 0
(0...(2 ** N)).each do |n|
  bits = (0..(N - 1)).map do |i|
    n[i] == 1
  end
  ret = s_list.all? do |i, slist|
    c = slist.count do |s|
      bits[s - 1]
    end
    c % 2 == p_list[i]
  end
  count += 1 if ret
end
puts count
