





'''simple docstring'''


def 		__a(SCREAMING_SNAKE_CASE_     :    str			):



    '''simple docstring'''





    _lowerCAmelCase			=					hex_num.strip()
    if not hex_num:
        raise ValueError("No value was passed to the function"			)

    _lowerCAmelCase			=					hex_num[0] == '-'
    if is_negative:
        _lowerCAmelCase			=					hex_num[1:]

    try:
        _lowerCAmelCase			=					int(_UpperCAmelCase						,				16			)
    except ValueError:
        raise ValueError("Invalid value was passed to the function"			)

    _lowerCAmelCase			=					''
    while int_num > 0:
        _lowerCAmelCase			=					str(int_num % 2			) + bin_str
        int_num >>= 1

    return int(("-" + bin_str) if is_negative else bin_str			)


if __name__ == "__main__":
       import doctest

       doctest.testmod()









"""simple docstring"""




from heapq import heappop, heappush

import numpy as np





def 						UpperCAmelCase__		(     _UpperCAmelCase ,					_UpperCAmelCase ,					_UpperCAmelCase ,					_UpperCAmelCase ,					):






  """simple docstring"""





  A_						,       A_  :       List[str]										=  grid.shape
  A_  :       Optional[int]										=  [-1, 1, 0, 0]
  A_  :       str										=  [0, 0, -1, 1]
  if allow_diagonal:
    dx += [-1, -1, 1, 1]
    dy += [-1, 1, -1, 1]

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

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

    if (x, y) == destination:
      A_  :       int										=  []
      while (x, y) != source:
        path.append((x, y)					)
        A_						,       A_  :       List[Any]										=  predecessors[x, y]
      path.append(_UpperCAmelCase					)  # add the source manually
      path.reverse()
      return matrix[destination], path

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

  return np.inf, []


if __name__ == "__main__":
   import doctest

   doctest.testmod()