program main
  implicit none
  integer :: n, m, i, j, input(11), s(10, 10), k(10), p(10)
  integer :: res, state
  read (*, *) n, m
  do i = 1, m
    read (*, *) k(i), s(i, 1:k(i))
  end do
  read (*, *) p(1:m)

  res = 0
  do state = 0, 2 ** n - 1
    if (satisfy(state)) res = res + 1
  end do
  write (*, "(i0)") res

  contains

  pure logical function satisfy(state)
    integer, intent(in) :: state  ! Bit
    integer :: i, j, cnt
    ! i-th switch is on if btest(state, i - 1)
    satisfy = .true.
    do i = 1, m
      cnt = 0
      do j = 1, k(i)
        if (btest(state, s(i, j) - 1)) cnt = cnt + 1
      end do
      if (mod(cnt, 2) /= p(i)) satisfy = .false.
    end do
  end function satisfy
end program main
