#N=gets.to_i
#S=gets.chomp
#A=(0...N).map{gets.to_i}
#sum=A.inject(&:+)
#B=gets.split.map(&:to_i)
 
$counter=0
def test(states,switch,ps)
  if states.size<N
    test(states+[0],switch,ps)
    test(states+[1],switch,ps)
  else
    flag=true
    M.times do |i|
      onsum=0
      N.times do |j|
        onsum+=1 if switch[i][j] && states[j]==1
      end
      flag=false if onsum%2!=ps[i]
    end
    $counter+=1 if flag
  end
end

N,M=gets.split.map(&:to_i)
switch=Array.new(M){Hash.new(false)}
M.times.map do |i|
  k,*other=gets.split
  other.map(&:to_i).each do |j|
    switch[i][j-1]=true
  end
end
ps=gets.split.map(&:to_i)

test([],switch,ps)
puts $counter