str = gets.split
N,M = str[0].to_i, str[1].to_i
a = [1,2,4,8,16,32,64,128,256,512,1024]

b = Array.new(M,0)
for x in 0...M
  str = gets.split
  for y in 1..str[0].to_i
    b[x] += a[str[y].to_i-1]
  end
end

c = 0
str = gets.split
for x in 0...M
  if str[x] == "1"
    c += a[x]
  end
end

answer = 0
d = 0
for x in 0...a[N]
  d = 0
  for y in 0...M
    if (x & b[y])/a[y]%2 == 1
      d = d ^ a[y]
    end
  end
  if d == c
    answer += 1
  end
end

puts answer