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

ans = 0
[0, 1].repeated_permutation(n) do |b|
  cnt = 1
  m.times do |i|
    judge = 0
    k[i].times do |j|
      judge += b[s[i][j]]
    end
    if judge % 2 != p[i]
      cnt = 0
      break
    end
  end
  if cnt == 1
    ans += 1
  end
end
puts ans
