



from collections.abc import Iterable
from typing import Generic, TypeVar

_lowerCAmelCase	:   str    =   TypeVar("_T")


class 	__snake_case   ( Generic[_T] ):
		def __init__(							self    ,a_ = None						):







						"""simple docstring"""
						lowerCAmelCase__		  =  list(iterable or []						)
						lowerCAmelCase__		  =  []
		def __len__(							self						):







						"""simple docstring"""
						return len(self._stacka						) + len(self._stacka						)
		def __repr__(							self						):







						"""simple docstring"""
						return f'Queue({tuple(self._stacka[::-1] + self._stacka						)})'
		def 						SCREAMING_SNAKE_CASE_					(							self    ,a_						):







						"""simple docstring"""
						self._stacka.append(a_						)



		def 						SCREAMING_SNAKE_CASE_					(							self						):







						"""simple docstring"""
						lowerCAmelCase__		  =  self._stacka.pop
						lowerCAmelCase__		  =  self._stacka.append

						if not self._stacka:
										while self._stacka:
														stacka_append(stacka_pop()						)

						if not self._stacka:
										raise IndexError('Queue is empty'						)
						return self._stacka.pop()


if __name__ == "__main__":
	from doctest import testmod

	testmod()


import functools
from typing import Any



def 		UpperCamelCase     (       _UpperCAmelCase  :   str ,			_UpperCAmelCase  :   list[str]  )   ->			bool:






						'''simple docstring'''

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

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

						# Build trie
						_lowercase       :	dict[str, Any]           =   {}
						_lowercase       :	List[Any]           =   "WORD_KEEPER"

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

																		_lowercase       :	Optional[int]           =   trie_node[c]

												_lowercase       :	str           =   True

						_lowercase       :	int           =   len(_UpperCAmelCase  )

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

												_lowercase       :	Union[str, Any]           =   trie
												for i in range(_UpperCAmelCase ,			_UpperCAmelCase  ):
																		_lowercase       :	List[str]           =   trie_node.get(string[i] ,			_UpperCAmelCase  )

																		if trie_node is None:
																								return False

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

												return False

						return is_breakable(0  )


if __name__ == "__main__":
							import doctest

							doctest.testmod()




