'''simple docstring'''




from math import pow






def 							snake_case__				(     _A:   int ,  _A:   int ,  _A:   int ,  _A:   int ,  _A:   int ,  )       ->      tuple[int, int]:

		'''simple docstring'''


		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     =    int(pow(_A ,  _A					)					)
		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   ,	lowerCAmelCase     =    backtrack(
				    _A ,  _A ,  current_number + 1 ,  _A ,  _A					)
				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   ,	lowerCAmelCase     =    backtrack(
				    _A ,  _A ,  current_number + 1 ,  _A ,  _A					)
		return current_sum, solutions_count






def 							snake_case__				(     _A:   int ,  _A:   int					)       ->      int:

		'''simple docstring'''


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

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


if __name__ == "__main__":
						import doctest

						doctest.testmod()





'''simple docstring'''




# A Bipartite Graph is a graph whose vertices can be divided into two independent sets,
# U and V such that every edge (u, v) either connects a vertex from U to V or a vertex
# from V to U. In other words, for every edge (u, v), either u belongs to U and v to V,
# or u belongs to V and v to U. We can also say that there is no edge that connects
# vertices of same set.






def 							snake_case__				(     _A:   Dict					)       ->      str:

		'''simple docstring'''


		lowerCAmelCase     =    [False] * len(_A					)
		lowerCAmelCase     =    [-1] * len(_A					)

		def dfs(_A:   Dict ,  _A:   Tuple					):
				lowerCAmelCase     =    True
				lowerCAmelCase     =    c
				for u in graph[v]:
						if not visited[u]:
								dfs(_A ,  1 - c					)

		for i in range(len(_A					)					):
				if not visited[i]:
						dfs(_A ,  0					)

		for i in range(len(_A					)					):
				for j in graph[i]:
						if color[i] == color[j]:
								return False

		return True


# Adjacency list of graph
__lowercase        =    {0: [1, 3], 1: [0, 2], 2: [1, 3], 3: [0, 2], 4: []}




print(check_bipartite_dfs(graph))




