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
end
p = gets.chomp.split.map(&:to_i)

ans = 0
[0, 1].repeated_permutation(n) do |a|
  flg = false
  m.times do |i|
    tmp = 0
    s[i].each do |t|
      tmp += a[t-1]
    end
    if tmp % 2 != p[i]
      flg = true
      break
    end
  end
  next if flg
  ans += 1
end
p ans
