

def        __lowercase   (  _A    ,     _A    ,     _A    ,     _A      )  ->    int:
      return len_board * len_board_column * row + column






def        __lowercase   (  _A    ,     _A    ,     _A    ,     _A    ,     _A    ,     _A    ,     )  ->    bool:






      if board[row][column] != word[word_index]:
            return False

      if word_index == len(__UpperCAmelCase      ) - 1:
            return True

      SCREAMING_SNAKE_CASE			:   List[str]	  = [(0, 1), (0, -1), (-1, 0), (1, 0)]
      SCREAMING_SNAKE_CASE			:   Optional[int]	  = len(__UpperCAmelCase      )
      SCREAMING_SNAKE_CASE			:   Optional[Any]	  = len(board[0]      )
      for direction in traverts_directions:
            SCREAMING_SNAKE_CASE			:   str	  = row + direction[0]
            SCREAMING_SNAKE_CASE			:   Optional[int]	  = column + direction[1]
            if not (0 <= next_i < len_board and 0 <= next_j < len_board_column):
                  continue

            SCREAMING_SNAKE_CASE			:   List[Any]	  = get_point_key(__UpperCAmelCase    ,     __UpperCAmelCase    ,     __UpperCAmelCase    ,     __UpperCAmelCase      )
            if key in visited_points_set:
                  continue

            visited_points_set.add(__UpperCAmelCase      )
            if exits_word(__UpperCAmelCase    ,     __UpperCAmelCase    ,     __UpperCAmelCase    ,     __UpperCAmelCase    ,     word_index + 1    ,     __UpperCAmelCase      ):
                  return True

            visited_points_set.remove(__UpperCAmelCase      )

      return False






def        __lowercase   (  _A    ,     _A      )  ->    bool:
      SCREAMING_SNAKE_CASE			:   str	  = (
          """The board should be a non empty matrix of single chars strings."""
      )

      SCREAMING_SNAKE_CASE			:   List[str]	  = len(__UpperCAmelCase      )
      if not isinstance(__UpperCAmelCase    ,     __UpperCAmelCase      ) or len(__UpperCAmelCase      ) == 0:
            raise ValueError(__UpperCAmelCase      )

      for row in board:
            if not isinstance(__UpperCAmelCase    ,     __UpperCAmelCase      ) or len(__UpperCAmelCase      ) == 0:
                  raise ValueError(__UpperCAmelCase      )

            for item in row:
                  if not isinstance(__UpperCAmelCase    ,     __UpperCAmelCase      ) or len(__UpperCAmelCase      ) != 1:
                        raise ValueError(__UpperCAmelCase      )

    # Validate word
      if not isinstance(__UpperCAmelCase    ,     __UpperCAmelCase      ) or len(__UpperCAmelCase      ) == 0:
            raise ValueError(
                """The word parameter should be a string of length greater than 0."""      )

      SCREAMING_SNAKE_CASE			:   Dict	  = len(board[0]      )
      for i in range(__UpperCAmelCase      ):
            for j in range(__UpperCAmelCase      ):
                  if exits_word(
                      __UpperCAmelCase    ,     __UpperCAmelCase    ,     __UpperCAmelCase    ,     __UpperCAmelCase    ,     0    ,     {get_point_key(__UpperCAmelCase    ,     __UpperCAmelCase    ,     __UpperCAmelCase    ,     __UpperCAmelCase      )}      ):
                        return True

      return False


if __name__ == "__main__":
  import doctest

  doctest.testmod()









def 							A     (						__UpperCAmelCase				,   __UpperCAmelCase      )			->			int:



						'''simple docstring'''






						print('''\nVertex Distance'''      )
						for i in range(__UpperCAmelCase      ):
												if dist[i] != float('''inf'''      ):
																		print(__UpperCAmelCase				,   '''\t'''				,   int(dist[i]      )				,   end='''\t'''      )
												else:
																		print(__UpperCAmelCase				,   '''\t'''				,   '''INF'''				,   end='''\t'''      )
												print()







def 							A     (						__UpperCAmelCase				,   __UpperCAmelCase				,   __UpperCAmelCase      )			->			str:



						'''simple docstring'''






						UpperCAmelCase_					=	float('''inf'''      )
						UpperCAmelCase_					=	-1
						for i in range(__UpperCAmelCase      ):
												if (not vset[i]) and mdist[i] < min_val:
																		UpperCAmelCase_					=	i
																		UpperCAmelCase_					=	mdist[i]
						return min_ind







def 							A     (						__UpperCAmelCase				,   __UpperCAmelCase				,   __UpperCAmelCase      )			->			Optional[Any]:



						'''simple docstring'''






						UpperCAmelCase_					=	[float('''inf'''      ) for _ in range(__UpperCAmelCase      )]
						UpperCAmelCase_					=	[False for _ in range(__UpperCAmelCase      )]
						UpperCAmelCase_					=	0.0

						for _ in range(v - 1      ):
												UpperCAmelCase_					=	min_dist(__UpperCAmelCase				,   __UpperCAmelCase				,   __UpperCAmelCase      )
												UpperCAmelCase_					=	True

												for i in range(__UpperCAmelCase      ):
																		if (
																		    (not vset[i])
																		    and graph[u][i] != float('''inf'''      )
																		    and mdist[u] + graph[u][i] < mdist[i]
																		):
																								UpperCAmelCase_					=	mdist[u] + graph[u][i]

						print_dist(__UpperCAmelCase				,   __UpperCAmelCase      )


if __name__ == "__main__":
							UpperCamelCase_      			=  int(input("Enter number of vertices: ").strip())
							UpperCamelCase_      			=  int(input("Enter number of edges: ").strip())

							UpperCamelCase_      			=  [[float("inf") for i in range(V)] for j in range(V)]

							for i in range(V):
														UpperCamelCase_      			=  0.0

							for i in range(E):
														print("\nEdge ", i + 1)
														UpperCamelCase_      			=  int(input("Enter source:").strip())
														UpperCamelCase_      			=  int(input("Enter destination:").strip())
														UpperCamelCase_      			=  float(input("Enter weight:").strip())
														UpperCamelCase_      			=  weight

							UpperCamelCase_      			=  int(input("\nEnter shortest path source:").strip())
							dijkstra(graph, V, gsrc)





