






"""simple docstring"""





from heapq import heappop, heappush

import numpy as np



def   a    (     __UpperCAmelCase      :    np.ndarray      ,   __UpperCAmelCase      :    tuple[int, int]      ,   __UpperCAmelCase      :    tuple[int, int]      ,   __UpperCAmelCase      :    bool      ,   )    ->							tuple[float | int, list[tuple[int, int]]]:
						__magic_name__,			__magic_name__:	Dict							=       grid.shape
						__magic_name__:	Optional[Any]							=       [-1, 1, 0, 0]
						__magic_name__:	int							=       [0, 0, -1, 1]
						if allow_diagonal:
												dx += [-1, -1, 1, 1]
												dy += [-1, 1, -1, 1]

						__magic_name__,			__magic_name__:	Any							=       [(0, source)], set()
						__magic_name__:	Optional[int]							=       np.full((rows, cols)      ,   np.inf  )
						__magic_name__:	int							=       0
						__magic_name__:	Tuple							=       np.empty((rows, cols)      ,   dtype=__UpperCAmelCase  )
						__magic_name__:	List[Any]							=       None

						while queue:
												((__magic_name__),			(__magic_name__)):	str							=       heappop(__UpperCAmelCase  )
												if (x, y) in visited:
																		continue
												visited.add((x, y)  )

												if (x, y) == destination:
																		__magic_name__:	Tuple							=       []
																		while (x, y) != source:
																								path.append((x, y)  )
																								__magic_name__,			__magic_name__:	Union[str, Any]							=       predecessors[x, y]
																		path.append(__UpperCAmelCase  )  # add the source manually
																		path.reverse()
																		return matrix[destination], path

												for i in range(len(__UpperCAmelCase  )  ):
																		__magic_name__,			__magic_name__:	List[Any]							=       x + dx[i], y + dy[i]
																		if 0 <= nx < rows and 0 <= ny < cols:
																								__magic_name__:	str							=       grid[nx][ny]
																								if next_node == 1 and matrix[nx, ny] > dist + 1:
																														heappush(__UpperCAmelCase      ,   (dist + 1, (nx, ny))  )
																														__magic_name__:	Union[str, Any]							=       dist + 1
																														__magic_name__:	Dict							=       (x, y)

						return np.inf, []


if __name__ == "__main__":
							import doctest

							doctest.testmod()





__lowerCamelCase				=			{
    0: """0""",
    1: """1""",
    2: """2""",
    3: """3""",
    4: """4""",
    5: """5""",
    6: """6""",
    7: """7""",
    8: """8""",
    9: """9""",
    10: """a""",
    11: """b""",
    12: """c""",
    13: """d""",
    14: """e""",
    15: """f""",
}


def      UpperCamelCase   (       __lowerCamelCase	:					float       ):
       assert type(__lowerCamelCase       ) in (int, float) and decimal == int(__lowerCamelCase       )
       snake_case			:  str     							= int(__lowerCamelCase       )
       snake_case			:  str     							= ""
       snake_case			:  str     							= False
       if decimal < 0:
              snake_case			:  Optional[Any]     							= True
              decimal *= -1
       while decimal > 0:
              snake_case							,   snake_case			:  Union[str, Any]     							= divmod(__lowerCamelCase							,   16       )
              snake_case			:  Tuple     							= values[remainder] + hexadecimal
       snake_case			:  Tuple     							= "0x" + hexadecimal
       if negative:
              snake_case			:  Any     							= "-" + hexadecimal
       return hexadecimal


if __name__ == "__main__":
   import doctest

   doctest.testmod()





