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

s = []
k = []
m.times do |i|
  s[i] = gets.split(" ").map(&:to_i)
  s[i].length.times do |j|
    s[i][j] -= 1
  end
  k[i] = s[i].shift
end

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

ans = 0
(1 << n).times do |i|
  #denkyu check
  m.times do |j|
    on = 0
    s[j].length.times do |k|
      on += 1 if 1 << s[j][k] & i > 0
    end
    break if on %2 != p[j]
    ans += 1 if j == m-1
  end
end

puts ans
