

from math import pow






def        SCREAMING_SNAKE_CASE__	(  lowerCamelCase__     ,			lowerCamelCase__     ,			lowerCamelCase__     ,			lowerCamelCase__     ,			lowerCamelCase__     ,			)  ->					Tuple:

	if current_sum == needed_sum:
		# If the sum of the powers is equal to needed_sum, then we have a solution.
		solutions_count += 1
		return current_sum, solutions_count

	__lowerCamelCase    :    Tuple 	=			int(pow(lowerCamelCase_     ,			lowerCamelCase_      )      )
	if current_sum + i_to_n <= needed_sum:
		# If the sum of the powers is less than needed_sum, then continue adding powers.
		current_sum += i_to_n
		__lowerCamelCase    :    int 	=			backtrack(
		    lowerCamelCase_     ,			lowerCamelCase_     ,			current_number + 1     ,			lowerCamelCase_     ,			lowerCamelCase_      )
		current_sum -= i_to_n
	if i_to_n < needed_sum:
		# If the power of i is less than needed_sum, then try with the next power.
		__lowerCamelCase    :    Any 	=			backtrack(
		    lowerCamelCase_     ,			lowerCamelCase_     ,			current_number + 1     ,			lowerCamelCase_     ,			lowerCamelCase_      )
	return current_sum, solutions_count






def        SCREAMING_SNAKE_CASE__	(  lowerCamelCase__     ,			lowerCamelCase__      )  ->					Dict:

	if not (1 <= needed_sum <= 1_0_0_0 and 2 <= power <= 1_0):
		raise ValueError(
		    'Invalid input\n'
		    'needed_sum must be between 1 and 1000, power between 2 and 10.'      )

	return backtrack(lowerCamelCase_     ,			lowerCamelCase_     ,			1     ,			0     ,			0      )[1]  # Return the solutions_count


if __name__ == "__main__":
					import doctest

					doctest.testmod()







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


a		={
    """configuration_mask2former""": [
        """MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """Mask2FormerConfig""",
    ],
}

try:
					if not is_vision_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					a		=["""Mask2FormerImageProcessor"""]

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					a		=[
					    """MASK2FORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
					    """Mask2FormerForUniversalSegmentation""",
					    """Mask2FormerModel""",
					    """Mask2FormerPreTrainedModel""",
					]

if TYPE_CHECKING:
					from .configuration_maskaformer import MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, MaskaFormerConfig

					try:
										if not is_vision_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .image_processing_maskaformer import MaskaFormerImageProcessor

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_maskaformer import (
										    MASK2FORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
										    MaskaFormerForUniversalSegmentation,
										    MaskaFormerModel,
										    MaskaFormerPreTrainedModel,
										)


else:
					import sys

					a		=_LazyModule(__name__, globals()["""__file__"""], _import_structure)




