def ret_num(s,k)
  temp=0
  for i in 0...k
    temp=temp+2**(s[i]-1)
  end
  return temp
end

def numofbits1(bits)
  num = 0
  mask = 1
  while(mask != 0) do
    break if 1 << 31  == mask
    num += 1 if (bits & mask) != 0
    mask <<= 1
  end
  num
end


def dec_r(mask,num,pp)
  bit_r=mask&num
  if (numofbits1(bit_r)%2)==pp
    result=1
  else
    result=0
  end
  return result
end

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

k=Array.new(m)
s=Array.new(m)
pp=Array.new(m)

for i in 0...m
  temp=gets.chop.split.map(&:to_i)
  k[i]=temp[0]
  s[i]=temp[1...temp.length]
end

pp=gets.chop.split.map(&:to_i)
count_r=0
count_d=1
num=[]
for i in 0...(2**n)
  num[i]=i  
  for j in 0...m
  	mask=ret_num(s[j],k[j])
    count_d*=count_d*dec_r(mask,num[i],pp[j])
  end
  if count_d==1
    count_r+=1
  end
end

puts count_r
