






"""simple docstring"""



from __future__ import annotations

from typing import Any






class 							__SCREAMING_SNAKE_CASE						:


							def __init__(			self      :						int			,    snake_case      :						int							):
													'''simple docstring'''





													A__						:  Optional[Any]		  =  num_of_nodes
													A__						:  list[list[int]]		  =  []
													A__						:  dict[int, int]		  =  {}


							def 						_UpperCamelCase       (			self      :						List[str]			,    snake_case      :						int			,    snake_case      :						int			,    snake_case      :						int							):
													'''simple docstring'''





													self.m_edges.append([u_node, v_node, weight]							)


							def 						_UpperCamelCase       (			self      :						List[str]			,    snake_case      :						int							):
													'''simple docstring'''





													if self.m_component[u_node] == u_node:
																			return u_node
													return self.find_component(self.m_component[u_node]							)


							def 						_UpperCamelCase       (			self      :						List[Any]			,    snake_case      :						int							):
													'''simple docstring'''





													if self.m_component[u_node] != u_node:
																			for k in self.m_component:
																									A__						:  List[str]		  =  self.find_component(snake_case							)


							def 						_UpperCamelCase       (			self      :						List[Any]			,    snake_case      :						list[int]			,    snake_case      :						int			,    snake_case      :						int							):
													'''simple docstring'''





													if component_size[u_node] <= component_size[v_node]:
																			A__						:  Tuple		  =  v_node
																			component_size[v_node] += component_size[u_node]
																			self.set_component(snake_case							)

													elif component_size[u_node] >= component_size[v_node]:
																			A__						:  Any		  =  self.find_component(snake_case							)
																			component_size[u_node] += component_size[v_node]
																			self.set_component(snake_case							)


							def 						_UpperCamelCase       (			self      :						Any							):
													'''simple docstring'''





													A__						:  List[Any]		  =  []
													A__						:  Union[str, Any]		  =  0

													A__						:  list[Any]		  =  [-1] * self.m_num_of_nodes

													# A list of components (initialized to all of the nodes)
													for node in range(self.m_num_of_nodes							):
																			self.m_component.update({node: node}							)
																			component_size.append(1							)

													A__						:  Any		  =  self.m_num_of_nodes

													while num_of_components > 1:
																			for edge in self.m_edges:
																									A__  ,  A__  ,  A__						:  Optional[int]		  =  edge

																									A__						:  int		  =  self.m_component[u]
																									A__						:  int		  =  self.m_component[v]

																									if u_component != v_component:

																															for component in (u_component, v_component):
																																					if (
																																					    minimum_weight_edge[component] == -1
																																					    or minimum_weight_edge[component][2] > w
																																					):
																																											A__						:  Optional[int]		  =  [u, v, w]

																			for edge in minimum_weight_edge:
																									if isinstance(snake_case			,    snake_case							):
																															A__  ,  A__  ,  A__						:  List[Any]		  =  edge

																															A__						:  Dict		  =  self.m_component[u]
																															A__						:  Dict		  =  self.m_component[v]

																															if u_component != v_component:
																																					mst_weight += w
																																					self.union(snake_case			,    snake_case			,    snake_case							)
																																					print(F'Added edge [{u} - {v}]\nAdded weight: {w}\n'							)
																																					num_of_components -= 1

																			A__						:  Optional[int]		  =  [-1] * self.m_num_of_nodes
													print(F'The total weight of the minimal spanning tree is: {mst_weight}'							)




def      _lowerCAmelCase		(							)		->None:
						pass


if __name__ == "__main__":
						import doctest

						doctest.testmod()














"""simple docstring"""



def      _lowerCAmelCase		(							UpperCAmelCase__       :					int,						UpperCAmelCase__       :					int      )		->str:
						if a < 0 or b < 0:
												raise ValueError("""the value of both inputs must be positive"""      )

						A__						:  str		  =  str(bin(UpperCAmelCase__      )      )[2:]  # remove the leading "0b"
						A__						:  List[Any]		  =  str(bin(UpperCAmelCase__      )      )[2:]  # remove the leading "0b"

						A__						:  List[str]		  =  max(len(UpperCAmelCase__      ),						len(UpperCAmelCase__      )      )

						return "0b" + "".join(
						    str(int(char_a == """1""" and char_b == """1"""      )      )
						    for char_a, char_b in zip(a_binary.zfill(UpperCAmelCase__      ),						b_binary.zfill(UpperCAmelCase__      )      )      )


if __name__ == "__main__":
						import doctest

						doctest.testmod()






