integer N,M
integer,allocatable,dimension(:)::k,p
integer,allocatable,dimension(:,:)::S
integer reader(10)
integer check,on,l,b
integer ans
read*,N,M
allocate(k(M),p(M),S(M,10))

S=0
do i=1,M
  reader=0
  read*,k(i),reader(1:k(i))
  do j=1,k(i)
    S(i,reader(j))=1
  end do
end do
read*,p

ans=0
do i=0,2**N
  check=0
  do j=1,M
    b=i
    on=0
    do l=1,N
      if(and(b,1)==1)on=mod(on+S(j,l),2)
      b=rshift(b,1)
    end do
    if(on/=p(j))check=1
  end do
  if(check==0)ans=ans+1
end do
print"(i0)",ans
end