      PROGRAM piyo
      IMPLICIT NONE
      integer :: n,m,p(10),k(10),sNum(10,10),ans=0
      logical :: s(10,10) = .false.,switch(10)
      integer :: i,j
      
      read*,n,m
      do i = 1,m
        read(fmt='(i2)',advance='no',unit=5) k(i)
        read*,sNum(i,1:k(i))
      end do
      read*,p(1:m)
      
      do i = 1,m
        do j = 1,k(i)
          s(i,sNum(i,j)) = .true.
        end do
      end do
 ! do i = 1,m
 !   print*,s(i,:)
 ! end do
      !s(n,k(i))
      
      
      outer:do i = 0,2**n-1
        switch = .false.
        do j = 1,n
          switch(j) = btest(i,j-1)
        end do
        
        do j = 1,m
          if(p(j)/= mod( count(switch(1:n).and.s(j,1:n)),2 ))then
            cycle outer
          end if
        end do
        ans = ans + 1
      end do outer
      
      print*,ans
      
 !debugg
  !    print*,n,m
  !    do i = 1,m
  !      print*,k(i),sNum(i,1:k(i))
  !    end do
  !    print*,p(1:m)
      
      END PROGRAM