


from __future__ import annotations

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : str      ,					SCREAMING_SNAKE_CASE__      : list[str] | None = None    ):
     __UpperCamelCase   							=word_bank or []
     # create a table
     __UpperCamelCase   							=len(SCREAMING_SNAKE_CASE__    ) + 1

     __UpperCamelCase   							=[]
     for _ in range(SCREAMING_SNAKE_CASE__    ):
          table.append([]    )
     # seed value
     __UpperCamelCase   							=[[]]  # because empty string has empty combination

     # iterate through the indices
     for i in range(SCREAMING_SNAKE_CASE__    ):
          # condition
          if table[i] != []:
               for word in word_bank:
                    # slice condition
                    if target[i : i + len(SCREAMING_SNAKE_CASE__    )] == word:
                         __UpperCamelCase   							=[
                             [word, *way] for way in table[i]
                         ]
                         # adds the word to every combination the current position holds
                         # now,push that combination to the table[i+len(word)]
                         table[i + len(SCREAMING_SNAKE_CASE__    )] += new_combinations

    # combinations are in reverse order so reverse for better output
     for combination in table[len(SCREAMING_SNAKE_CASE__    )]:
          combination.reverse()

     return table[len(SCREAMING_SNAKE_CASE__    )]


if __name__ == "__main__":
   print(all_construct('jwajalapa', ['jwa', 'j', 'w', 'a', 'la', 'lapa']))
   print(all_construct('rajamati', ['s', 'raj', 'amat', 'raja', 'ma', 'i', 't']))
   print(
       all_construct(
           'hexagonosaurus',
           ['h', 'ex', 'hex', 'ag', 'ago', 'ru', 'auru', 'rus', 'go', 'no', 'o', 's'],
       )
   )









from __future__ import annotations

from typing import Any

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : list[Any]    ):
     create_state_space_tree(SCREAMING_SNAKE_CASE__      ,					[]      ,					0    )

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : list[Any]      ,					SCREAMING_SNAKE_CASE__      : list[Any]      ,					SCREAMING_SNAKE_CASE__      : int    ):

     if index == len(SCREAMING_SNAKE_CASE__    ):
          print(SCREAMING_SNAKE_CASE__    )
          return

     create_state_space_tree(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__      ,					index + 1    )
     current_subsequence.append(sequence[index]    )
     create_state_space_tree(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__      ,					index + 1    )
     current_subsequence.pop()


if __name__ == "__main__":
   _A			=						[3, 1, 2, 4]
   generate_all_subsequences(seq)

   seq.clear()
   seq.extend(['A', 'B', 'C'])
   generate_all_subsequences(seq)





