PROGRAM ATCODER

implicit none
integer(16) :: n,m,i,max=0,l,count=0,h,j,on,check=0
integer(16),allocatable :: k(:),s(:,:),p(:),sw(:)

read*, n,m
allocate(k(m),s(m,10),p(m),sw(n))
s = 0
do i = 1, m, 1
  read*, k(i),s(i,1:k(i))
end do
read*, p(1:m)

do i = 1, n
  max = max + 2**(i-1)
end do

do i = 0, max, 1
  check = 0
  l = i
  sw = 0
  do j = 1, n, 1
    sw(j) = mod(l,2)
    l = l/2
  end do
  do j = 1, m, 1
    on = 0
    do h = 1, k(m), 1
      if ( sw(s(j,h)) == 1 ) then
        on = on + 1
      end if
    end do
    if ( mod(on,2) /= p(j) ) then
      check = 1
    end if
  end do
  if ( check == 0 ) then
    count = count + 1
  end if
end do

print'(i0)', count

END PROGRAM ATCODER