




from heapq import heappop, heappush

import numpy as np







def      lowerCamelCase_						(			UpperCamelCase__							: np.ndarray					,	UpperCamelCase__							: tuple[int, int]					,	UpperCamelCase__							: tuple[int, int]					,	UpperCamelCase__							: bool					,	)	->			tuple[float | int, list[tuple[int, int]]]:





				"""simple docstring"""


				__lowerCamelCase			,		__lowerCamelCase									=       grid.shape
				__lowerCamelCase									=       [-1, 1, 0, 0]
				__lowerCamelCase									=       [0, 0, -1, 1]
				if allow_diagonal:
								dx += [-1, -1, 1, 1]
								dy += [-1, 1, -1, 1]

				__lowerCamelCase			,		__lowerCamelCase									=       [(0, source)], set()
				__lowerCamelCase									=       np.full((rows, cols)					,	np.inf )
				__lowerCamelCase									=       0
				__lowerCamelCase									=       np.empty((rows, cols)					,	dtype=UpperCamelCase__ )
				__lowerCamelCase									=       None

				while queue:
								((__lowerCamelCase)			,		(__lowerCamelCase))									=       heappop(UpperCamelCase__ )
								if (x, y) in visited:
												continue
								visited.add((x, y) )

								if (x, y) == destination:
												__lowerCamelCase									=       []
												while (x, y) != source:
																path.append((x, y) )
																__lowerCamelCase			,		__lowerCamelCase									=       predecessors[x, y]
												path.append(UpperCamelCase__ )  # add the source manually
												path.reverse()
												return matrix[destination], path

								for i in range(len(UpperCamelCase__ ) ):
												__lowerCamelCase			,		__lowerCamelCase									=       x + dx[i], y + dy[i]
												if 0 <= nx < rows and 0 <= ny < cols:
																__lowerCamelCase									=       grid[nx][ny]
																if next_node == 1 and matrix[nx, ny] > dist + 1:
																				heappush(UpperCamelCase__					,	(dist + 1, (nx, ny)) )
																				__lowerCamelCase									=       dist + 1
																				__lowerCamelCase									=       (x, y)

				return np.inf, []


if __name__ == "__main__":
					import doctest

					doctest.testmod()








from string import ascii_uppercase

__A								=       {str(ord(c) - 55): c for c in ascii_uppercase}







def      lowerCamelCase_						(			UpperCamelCase__							: int					,	UpperCamelCase__							: int )	->			str:





				"""simple docstring"""


				if isinstance(UpperCamelCase__					,	UpperCamelCase__ ):
								raise TypeError('int() can\'t convert non-string with explicit base' )
				if num < 0:
								raise ValueError('parameter must be positive int' )
				if isinstance(UpperCamelCase__					,	UpperCamelCase__ ):
								raise TypeError('\'str\' object cannot be interpreted as an integer' )
				if isinstance(UpperCamelCase__					,	UpperCamelCase__ ):
								raise TypeError('\'float\' object cannot be interpreted as an integer' )
				if base in (0, 1):
								raise ValueError('base must be >= 2' )
				if base > 36:
								raise ValueError('base must be <= 36' )
				__lowerCamelCase									=       ''
				__lowerCamelCase									=       0
				__lowerCamelCase									=       0
				while div != 1:
								__lowerCamelCase			,		__lowerCamelCase									=       divmod(UpperCamelCase__					,	UpperCamelCase__ )
								if base >= 11 and 9 < mod < 36:
												__lowerCamelCase									=       ALPHABET_VALUES[str(UpperCamelCase__ )]
								else:
												__lowerCamelCase									=       str(UpperCamelCase__ )
								new_value += actual_value
								__lowerCamelCase									=       num // base
								__lowerCamelCase									=       div
								if div == 0:
												return str(new_value[::-1] )
								elif div == 1:
												new_value += str(UpperCamelCase__ )
												return str(new_value[::-1] )

				return new_value[::-1]


if __name__ == "__main__":
					import doctest

					doctest.testmod()

					for base in range(2, 37):
										for num in range(10_00):
															assert int(decimal_to_any(num, base), base) == num, (
															    num,
															    base,
															    decimal_to_any(num, base),
															    int(decimal_to_any(num, base), base),
															)


