program ccc
implicit none

integer :: n, m, i, j, k, l, sw, res
integer,dimension(10) ::  kk, p, switch, counter
integer,dimension(10,10) :: s
logical :: ch

kk=0
p=0
s=0
res=0

read*, n, m
do i=1,m
read*, kk(i), s(1:kk(i),i)
end do
read*, p(1:m)

do i=0,2**n-1
switch=0
sw=0
 
 do j=0,n-1
  if(btest(i,j)) then
  sw=sw+1
  switch(sw)=j+1
  end if
 end do
  
 counter=0
 
 do j=1,m
  do k=1,10
  if(s(k,j)==0) exit 
   do l=1,sw
    if(s(k,j)==switch(l)) then
    counter(j)=counter(j)+1
    exit
    end if
   end do
  end do
 end do

 ch=.True.

 do j=1,m
  if(mod(counter(j),2)/=p(j)) then
  ch=.False.
  exit
  end if
 end do
 if (ch) res=res+1
end do

write(*,'(i0)') res

end program