




from __future__ import annotations
def 		a_							( __lowerCAmelCase   , __lowerCAmelCase				):
  lowerCAmelCase__										=      []
  lowerCAmelCase__										=      []
  lowerCAmelCase__										=      0
  lowerCAmelCase__										=      sum(__lowerCAmelCase				)
  create_state_space_tree(__lowerCAmelCase   , __lowerCAmelCase   , __lowerCAmelCase   , __lowerCAmelCase   , __lowerCAmelCase   , __lowerCAmelCase				)
  return result
def 		a_							( __lowerCAmelCase   , __lowerCAmelCase   , __lowerCAmelCase   , __lowerCAmelCase   , __lowerCAmelCase   , __lowerCAmelCase   , ):
  if sum(__lowerCAmelCase				) > max_sum or (remaining_nums_sum + sum(__lowerCAmelCase				)) < max_sum:
    return
  if sum(__lowerCAmelCase				) == max_sum:
    result.append(__lowerCAmelCase				)
    return
  for index in range(__lowerCAmelCase   , len(__lowerCAmelCase				)				):
    create_state_space_tree(
        __lowerCAmelCase   , __lowerCAmelCase   , index + 1   , [*path, nums[index]]   , __lowerCAmelCase   , remaining_nums_sum - nums[index]   , )
__magic_name__  :  Tuple					=       [3, 34, 4, 12, 5, 2]
__magic_name__  :  Optional[Any]					=       9
__magic_name__  :  List[Any]					=       generate_sum_of_subsets_soln(nums, max_sum)




print(*result)







from __future__ import annotations
def 		a_							( __lowerCAmelCase   , __lowerCAmelCase = None				):
  lowerCAmelCase__										=      word_bank or []
  # create a table
  lowerCAmelCase__										=      len(__lowerCAmelCase				) + 1

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

  # iterate through the indices
  for i in range(__lowerCAmelCase				):
    # condition
    if table[i] != []:
      for word in word_bank:
        # slice condition
        if target[i : i + len(__lowerCAmelCase				)] == word:
          lowerCAmelCase__										=      [
              [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(__lowerCAmelCase				)] += new_combinations

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

  return table[len(__lowerCAmelCase				)]


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"""],
          )
      )

