#!/usr/bin/env ruby

nn, mm = gets.chomp.split.map(&:to_i)
ss = []
1.step(mm, 1) do |_i|
  k = gets.chomp.split.map(&:to_i)
  ss[_i - 1] = k[1..-1]
end
ps = gets.chomp.split.map(&:to_i)

ans = 0
0.step((2**nn) - 1, 1) do |bit2s|
  flag = true
  0.step(mm - 1, 1) do |ite_m|
    sum = 0
    ss[ite_m].each do |swi|
      next if bit2s[swi-1].to_i != 1
      sum += 1
    end
    if sum%2 != ps[ite_m]%2
      flag = false
      break
    end
  end
  ans += 1 if flag
end

p ans

=begin

# 一行に整数ひとつだけ
n = gets.chomp.to_i
p n

# 半角区切り整数を配列で受ける
# k1, k2 , ...
k = gets.chomp.split.map(&:to_i)

p k

# n
# a1, b1
# ...
# an, bn
# の形式

nn = gets.chomp.to_i
p nn
a = []
b = []
0.step(nn-1) do |i|
  k = gets.chomp.split(' ').map(&:to_i)
  a << k[0]
  b << k[1]
end

0.step(nn-1) { |i|
  puts "i: #{i} a:#{a[i]} b:#{b[i]}"
}

=end