n, m = gets.chomp.split.map(&:to_i)
list = []
m.times do |i|
  s = gets.chomp.split.map(&:to_i)
  k = s.shift
  list[i] = [0] * n
  k.times do |j|
    list[i][s[j]-1] = 1
  end
end

p = gets.chomp.split.map(&:to_i)

count = 0
[0, 1].repeated_permutation(n) do |s|
  m.times do |i|
    break if list[i].zip(s).map{ |listi, si| listi * si }.reduce(&:+)%2 != p[i]
    count += 1 if i == m-1
  end
end

puts(count)