





class    _a     :






							"""simple docstring"""

							def __init__(      self				:     List[str]    )	->Optional[int]:
													SCREAMING_SNAKE_CASE__     :				Tuple   =					0
													SCREAMING_SNAKE_CASE__     :				Tuple   =					0
													SCREAMING_SNAKE_CASE__     :				Any   =					{}

							def      A_  (      self				:     Any							,	a				:     List[Any]    )	->List[Any]:
													if vertex not in self.adjacency:
																			SCREAMING_SNAKE_CASE__     :				List[str]   =					{}
																			self.num_vertices += 1

							def      A_  (      self				:     int							,	a				:     List[Any]							,	a				:     Optional[int]							,	a				:     Dict    )	->Tuple:
													self.add_vertex(a    )
													self.add_vertex(a    )

													if head == tail:
																			return

													SCREAMING_SNAKE_CASE__     :				Dict   =					weight
													SCREAMING_SNAKE_CASE__     :				Dict   =					weight

							def      A_  (      self				:     Dict    )	->str:
													SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					self.get_edges()
													for edge in edges:
																			SCREAMING_SNAKE_CASE__,							SCREAMING_SNAKE_CASE__,							SCREAMING_SNAKE_CASE__     :				Any   =					edge
																			edges.remove((tail, head, weight)    )
													for i in range(len(a    )    ):
																			SCREAMING_SNAKE_CASE__     :				Optional[Any]   =					list(edges[i]    )

													edges.sort(key=lambda a    : e[2]    )
													for i in range(len(a    ) - 1    ):
																			if edges[i][2] >= edges[i + 1][2]:
																									SCREAMING_SNAKE_CASE__     :				Any   =					edges[i][2] + 1
													for edge in edges:
																			SCREAMING_SNAKE_CASE__,							SCREAMING_SNAKE_CASE__,							SCREAMING_SNAKE_CASE__     :				int   =					edge
																			SCREAMING_SNAKE_CASE__     :				int   =					weight
																			SCREAMING_SNAKE_CASE__     :				List[Any]   =					weight

							def __str__(      self				:     List[Any]    )	->Optional[Any]:
													SCREAMING_SNAKE_CASE__     :				List[Any]   =					""
													for tail in self.adjacency:
																			for head in self.adjacency[tail]:
																									SCREAMING_SNAKE_CASE__     :				str   =					self.adjacency[head][tail]
																									string += f"""{head} -> {tail} == {weight}\n"""
													return string.rstrip("\n"    )

							def      A_  (      self				:     Optional[int]    )	->Optional[Any]:
													SCREAMING_SNAKE_CASE__     :				Optional[int]   =					[]
													for tail in self.adjacency:
																			for head in self.adjacency[tail]:
																									output.append((tail, head, self.adjacency[head][tail])    )
													return output

							def      A_  (      self				:     Tuple    )	->Optional[Any]:
													return self.adjacency.keys()

							@staticmethod
							def      A_  (      a				:     int=None							,	a				:     Any=None    )	->List[Any]:
													SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					Graph()
													if vertices is None:
																			SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					[]
													if edges is None:
																			SCREAMING_SNAKE_CASE__     :				Dict   =					[]
													for vertex in vertices:
																			g.add_vertex(a    )
													for edge in edges:
																			g.add_edge(*a    )
													return g



							class    _a     :






														"""simple docstring"""

														def __init__(      self				:     Optional[Any]    )	->List[str]:
																				SCREAMING_SNAKE_CASE__     :				str   =					{}
																				SCREAMING_SNAKE_CASE__     :				List[Any]   =					{}

														def __len__(      self				:     Any    )	->List[str]:
																				return len(self.parent    )

														def      A_  (      self				:     str							,	a				:     Dict    )	->List[str]:
																				if item in self.parent:
																										return self.find(a    )

																				SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					item
																				SCREAMING_SNAKE_CASE__     :				List[Any]   =					0
																				return item

														def      A_  (      self				:     Optional[Any]							,	a				:     Any    )	->Any:
																				if item not in self.parent:
																										return self.make_set(a    )
																				if item != self.parent[item]:
																										SCREAMING_SNAKE_CASE__     :				Any   =					self.find(self.parent[item]    )
																				return self.parent[item]






														def      A_  (      self				:     Dict							,	a				:     List[str]							,	a				:     Optional[Any]    )	->List[Any]:
																				SCREAMING_SNAKE_CASE__     :				Optional[int]   =					self.find(a    )
																				SCREAMING_SNAKE_CASE__     :				Optional[Any]   =					self.find(a    )

																				if roota == roota:
																										return roota

																				if self.rank[roota] > self.rank[roota]:
																										SCREAMING_SNAKE_CASE__     :				List[Any]   =					roota
																										return roota

																				if self.rank[roota] < self.rank[roota]:
																										SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					roota
																										return roota

																				if self.rank[roota] == self.rank[roota]:
																										self.rank[roota] += 1
																										SCREAMING_SNAKE_CASE__     :				Optional[int]   =					roota
																										return roota
																				return None







							@staticmethod
							def      A_  (      a				:     Optional[Any]    )	->List[str]:
													SCREAMING_SNAKE_CASE__     :				Optional[int]   =					graph.num_vertices

													SCREAMING_SNAKE_CASE__     :				int   =					Graph.UnionFind()
													SCREAMING_SNAKE_CASE__     :				str   =					[]
													while num_components > 1:
																			SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					{}
																			for vertex in graph.get_vertices():
																									SCREAMING_SNAKE_CASE__     :				List[Any]   =					-1

																			SCREAMING_SNAKE_CASE__     :				Dict   =					graph.get_edges()
																			for edge in edges:
																									SCREAMING_SNAKE_CASE__,							SCREAMING_SNAKE_CASE__,							SCREAMING_SNAKE_CASE__     :				Tuple   =					edge
																									edges.remove((tail, head, weight)    )
																			for edge in edges:
																									SCREAMING_SNAKE_CASE__,							SCREAMING_SNAKE_CASE__,							SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					edge
																									SCREAMING_SNAKE_CASE__     :				Optional[int]   =					union_find.find(a    )
																									SCREAMING_SNAKE_CASE__     :				int   =					union_find.find(a    )
																									if seta != seta:
																															if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
																																					SCREAMING_SNAKE_CASE__     :				Optional[int]   =					[head, tail, weight]

																															if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
																																					SCREAMING_SNAKE_CASE__     :				Optional[int]   =					[head, tail, weight]
																			for vertex in cheap_edge:
																									if cheap_edge[vertex] != -1:
																															SCREAMING_SNAKE_CASE__,							SCREAMING_SNAKE_CASE__,							SCREAMING_SNAKE_CASE__     :				int   =					cheap_edge[vertex]
																															if union_find.find(a    ) != union_find.find(a    ):
																																					union_find.union(a							,	a    )
																																					mst_edges.append(cheap_edge[vertex]    )
																																					SCREAMING_SNAKE_CASE__     :				str   =					num_components - 1
													SCREAMING_SNAKE_CASE__     :				str   =					Graph.build(edges=a    )
													return mst






from __future__ import annotations







def       UpperCAmelCase							(     _lowerCamelCase      :  list[int | float]			,   _lowerCamelCase      :  int			,   _lowerCamelCase      :  int     ):





						'''simple docstring'''


						if len(_lowerCamelCase     ) == 0:
												raise ValueError("find_max() arg is an empty sequence"     )
						if (
						    left >= len(_lowerCamelCase     )
						    or left < -len(_lowerCamelCase     )
						    or right >= len(_lowerCamelCase     )
						    or right < -len(_lowerCamelCase     )
						):
												raise IndexError("list index out of range"     )
						if left == right:
												return nums[left]
						SCREAMING_SNAKE_CASE__     :				Optional[int]   =					(left + right) >> 1  # the middle
						SCREAMING_SNAKE_CASE__     :				List[Any]   =					find_max(_lowerCamelCase			,   _lowerCamelCase			,   _lowerCamelCase     )  # find max in range[left, mid]
						SCREAMING_SNAKE_CASE__     :				Optional[int]   =					find_max(_lowerCamelCase			,   mid + 1			,   _lowerCamelCase     )  # find max in range[mid + 1, right]

						return left_max if left_max >= right_max else right_max


if __name__ == "__main__":
				import doctest

				doctest.testmod(verbose=True)