
'''simple docstring'''





from __future__ import annotations

from typing import Generic, TypeVar

UpperCAmelCase    					=   TypeVar("T")

class 						a   (				Generic[T]    ):




				def __init__(							self	:				int,    SCREAMING_SNAKE_CASE_	:				T      ):
										snake_case       :     Any =    data
										snake_case       :     Dict =    self
										snake_case       :     Any =    0




class 						a   (				Generic[T]    ):




				def __init__(							self	:				List[str]      ):
										# map from node name to the node object
										snake_case       :     dict[T, DisjointSetTreeNode[T]] =    {}




				def 	__snake_case							(							self	:				Tuple,    SCREAMING_SNAKE_CASE_	:				T      ):
										# create a new set with x as its member
										snake_case       :     List[str] =    DisjointSetTreeNode(SCREAMING_SNAKE_CASE_      )




				def 	__snake_case							(							self	:				Any,    SCREAMING_SNAKE_CASE_	:				T      ):
										# find the set x belongs to (with path-compression)
										snake_case       :     str =    self.map[data]
										if elem_ref != elem_ref.parent:
																snake_case       :     List[str] =    self.find_set(elem_ref.parent.data      )
										return elem_ref.parent




				def 	__snake_case							(							self	:				Union[str, Any],    SCREAMING_SNAKE_CASE_	:				DisjointSetTreeNode[T],    SCREAMING_SNAKE_CASE_	:				DisjointSetTreeNode[T]      ):
										# helper function for union operation
										if nodea.rank > nodea.rank:
																snake_case       :     List[Any] =    nodea
										else:
																snake_case       :     Tuple =    nodea
																if nodea.rank == nodea.rank:
																						nodea.rank += 1




				def 	__snake_case							(							self	:				List[Any],    SCREAMING_SNAKE_CASE_	:				T,    SCREAMING_SNAKE_CASE_	:				T      ):
										# merge 2 disjoint sets
										self.link(self.find_set(SCREAMING_SNAKE_CASE_      ),    self.find_set(SCREAMING_SNAKE_CASE_      )      )




class 						a   (				Generic[T]    ):




				def __init__(							self	:				List[Any]      ):
										# connections: map from the node to the neighbouring nodes (with weights)
										snake_case       :     dict[T, dict[T, int]] =    {}




				def 	__snake_case							(							self	:				List[Any],    SCREAMING_SNAKE_CASE_	:				T      ):
										# add a node ONLY if its not present in the graph
										if node not in self.connections:
																snake_case       :     List[Any] =    {}




				def 	__snake_case							(							self	:				Any,    SCREAMING_SNAKE_CASE_	:				T,    SCREAMING_SNAKE_CASE_	:				T,    SCREAMING_SNAKE_CASE_	:				int      ):
										# add an edge with the given weight
										self.add_node(SCREAMING_SNAKE_CASE_      )
										self.add_node(SCREAMING_SNAKE_CASE_      )
										snake_case       :     str =    weight
										snake_case       :     List[Any] =    weight




				def 	__snake_case							(							self	:				int      ):
										snake_case       :     List[Any] =    []
										snake_case       :     Dict =    set()
										for start in self.connections:
																for end in self.connections[start]:
																						if (start, end) not in seen:
																												seen.add((end, start)      )
																												edges.append((start, end, self.connections[start][end])      )
										edges.sort(key=lambda SCREAMING_SNAKE_CASE_      : x[2]      )

										# creating the disjoint set
										snake_case       :     Tuple =    DisjointSetTree[T]()
										for node in self.connections:
																disjoint_set.make_set(SCREAMING_SNAKE_CASE_      )

										# MST generation
										snake_case       :     List[str] =    0
										snake_case       :     List[Any] =    0
										snake_case       :     Optional[int] =    GraphUndirectedWeighted[T]()
										while num_edges < len(self.connections      ) - 1:
																snake_case,					snake_case,					snake_case       :     Optional[Any] =    edges[index]
																index += 1
																snake_case       :     Tuple =    disjoint_set.find_set(SCREAMING_SNAKE_CASE_      )
																snake_case       :     List[Any] =    disjoint_set.find_set(SCREAMING_SNAKE_CASE_      )
																if parent_u != parent_v:
																						num_edges += 1
																						graph.add_edge(SCREAMING_SNAKE_CASE_,    SCREAMING_SNAKE_CASE_,    SCREAMING_SNAKE_CASE_      )
																						disjoint_set.union(SCREAMING_SNAKE_CASE_,    SCREAMING_SNAKE_CASE_      )
										return graph



'''simple docstring'''





from __future__ import annotations

def      A (       A_							:					list[int]    ,							A_							:					int       ):
						snake_case       :     list[list[int]] =    []
						snake_case       :     list[int] =    []
						snake_case       :     int =    0
						snake_case       :     int =    sum(A_       )
						create_state_space_tree(A_    ,							A_    ,							A_    ,							A_    ,							A_    ,							A_       )
						return result

def      A (       A_							:					list[int]    ,							A_							:					int    ,							A_							:					int    ,							A_							:					list[int]    ,							A_							:					list[list[int]]    ,							A_							:					int    ,							):
						if sum(A_       ) > max_sum or (remaining_nums_sum + sum(A_       )) < max_sum:
												return
						if sum(A_       ) == max_sum:
												result.append(A_       )
												return
						for index in range(A_    ,							len(A_       )       ):
												create_state_space_tree(
												    A_    ,							A_    ,							index + 1    ,							[*path, nums[index]]    ,							A_    ,							remaining_nums_sum - nums[index]    ,							)
UpperCAmelCase    					=   [3, 34, 4, 12, 5, 2]
UpperCAmelCase    					=   9
UpperCAmelCase    					=   generate_sum_of_subsets_soln(nums, max_sum)





print(*result)

