






'''simple docstring'''






import functools
from typing import Any




def        _SCREAMING_SNAKE_CASE  (				A  :       str  ,		A  :       list[str]  )    -> str:







   """simple docstring"""







   if not isinstance(lowerCAmelCase__  ,		lowerCAmelCase__  ) or len(lowerCAmelCase__  ) == 0:
      raise ValueError('the string should be not empty string'  )

   if not isinstance(lowerCAmelCase__  ,		lowerCAmelCase__  ) or not all(
       isinstance(lowerCAmelCase__  ,		lowerCAmelCase__  ) and len(lowerCAmelCase__  ) > 0 for item in words  ):
      raise ValueError('the words should be a list of non-empty strings'  )

   # Build trie
   __snake_case				:      dict[str, Any]     							= {}
   __snake_case				:      Dict     							= 'WORD_KEEPER'

   for word in words:
      __snake_case				:      List[Any]     							= trie
      for c in word:
         if c not in trie_node:
            __snake_case				:      str     							= {}

         __snake_case				:      Any     							= trie_node[c]

      __snake_case				:      Optional[int]     							= True

   __snake_case				:      List[str]     							= len(lowerCAmelCase__  )

   # Dynamic programming method
   @functools.cache
   def is_breakable(A  :       int  ) -> bool:
      if index == len_string:
         return True

      __snake_case				:      Tuple     							= trie
      for i in range(lowerCAmelCase__  ,		lowerCAmelCase__  ):
         __snake_case				:      Dict     							= trie_node.get(string[i]  ,		lowerCAmelCase__  )

         if trie_node is None:
            return False

         if trie_node.get(lowerCAmelCase__  ,		lowerCAmelCase__  ) and is_breakable(i + 1  ):
            return True

      return False

   return is_breakable(0  )


if __name__ == "__main__":
      import doctest

      doctest.testmod()







'''simple docstring'''






import math




class a_    :







   def __init__(self					,   __a=0)			->      Any:  # a graph with Node 0,1,...,N-1
      """simple docstring"""






      __snake_case				:      List[str]     							= n
      __snake_case				:      Tuple     							= [
          [math.inf for j in range(0					,   __a)] for i in range(0					,   __a)
      ]  # adjacency matrix for weight
      __snake_case				:      Union[str, Any]     							= [
          [math.inf for j in range(0					,   __a)] for i in range(0					,   __a)
      ]  # dp[i][j] stores minimum distance from i to j







   def     SCREAMING_SNAKE_CASE__					(self					,   __a					,   __a					,   __a)			->      Tuple:
      """simple docstring"""






      __snake_case				:      Union[str, Any]     							= w







   def     SCREAMING_SNAKE_CASE__					(self)			->      Tuple:
      """simple docstring"""






      for k in range(0					,   self.n):
         for i in range(0					,   self.n):
            for j in range(0					,   self.n):
               __snake_case				:      List[Any]     							= min(self.dp[i][j]					,   self.dp[i][k] + self.dp[k][j])







   def     SCREAMING_SNAKE_CASE__					(self					,   __a					,   __a)			->      Optional[int]:
      """simple docstring"""






      return self.dp[u][v]


if __name__ == "__main__":
      __A    	=   Graph(5)
      graph.add_edge(0, 2, 9)
      graph.add_edge(0, 4, 1_0)
      graph.add_edge(1, 3, 5)
      graph.add_edge(2, 3, 7)
      graph.add_edge(3, 0, 1_0)
      graph.add_edge(3, 1, 2)
      graph.add_edge(3, 2, 1)
      graph.add_edge(3, 4, 6)
      graph.add_edge(4, 1, 3)
      graph.add_edge(4, 2, 4)
      graph.add_edge(4, 3, 9)
      graph.floyd_warshall()
      graph.show_min(1, 4)
      graph.show_min(0, 3)