n , m = gets.chomp.split.map(&:to_i)
sarr = Array.new(m)
m.times do |i|
	sarr[i] = gets.chomp.split.map(&:to_i).map{|s| s- 1}
	sarr[i] = sarr[i].slice(1, sarr[i].length-1)
end 
parr = gets.chomp.split.map(&:to_i)


def check(sarr, parr, bits)
	sarr.length.times do |i|
		cnt = 0
		sarr[i].each do |ss|
			cnt += 1 if bits[ss]
		end
		return false if cnt.even? != parr[i].even? 
	end
	return true
end



ccnt = 0
[false, true].repeated_permutation(n) do |bits|
	ok = check(sarr, parr, bits)
	#p bits 
	#puts "ok:#{ok}"; puts
	ccnt += 1 if ok 
end

puts ccnt