Prolog implementation to solve the multiple dwellers problem