from __future__ import annotations

from typing import Generic, TypeVar

_UpperCAmelCase          =						TypeVar("""T""")





class UpperCAmelCase		(   Generic[T]    ):


				'''simple docstring'''






				def __init__(		self						,      lowercase   ):



						"""simple docstring"""





						A_						:							Optional[Any]      = data
						A_						:							Optional[Any]      = self
						A_						:							List[str]      = 0





class UpperCAmelCase		(   Generic[T]    ):


				'''simple docstring'''






				def __init__(		self   ):



						"""simple docstring"""





						A_						:							dict[T, DisjointSetTreeNode[T]]      = {}
				def     lowerCAmelCase_  (		self						,      lowercase   ):



						"""simple docstring"""





						A_						:							Union[str, Any]      = DisjointSetTreeNode(lowercase   )
				def     lowerCAmelCase_  (		self						,      lowercase   ):



						"""simple docstring"""





						A_						:							str      = self.map[data]
						if elem_ref != elem_ref.parent:
								A_						:							Tuple      = self.find_set(elem_ref.parent.data   )
						return elem_ref.parent
				def     lowerCAmelCase_  (		self						,      lowercase						,      lowercase   ):



						"""simple docstring"""





						if nodea.rank > nodea.rank:
								A_						:							Optional[Any]      = nodea
						else:
								A_						:							Any      = nodea
								if nodea.rank == nodea.rank:
										nodea.rank += 1







				def     lowerCAmelCase_  (		self						,      lowercase						,      lowercase   ):



						"""simple docstring"""





						self.link(self.find_set(lowercase   )						,      self.find_set(lowercase   )   )





class UpperCAmelCase		(   Generic[T]    ):


				'''simple docstring'''






				def __init__(		self   ):



						"""simple docstring"""





						A_						:							dict[T, dict[T, int]]      = {}
				def     lowerCAmelCase_  (		self						,      lowercase   ):



						"""simple docstring"""





						if node not in self.connections:
								A_						:							Dict      = {}
				def     lowerCAmelCase_  (		self						,      lowercase						,      lowercase						,      lowercase   ):



						"""simple docstring"""





						self.add_node(lowercase   )
						self.add_node(lowercase   )
						A_						:							int      = weight
						A_						:							Optional[Any]      = weight







				def     lowerCAmelCase_  (		self   ):



						"""simple docstring"""





						A_						:							Optional[Any]      = []
						A_						:							int      = 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 lowercase   : x[2]   )

						# creating the disjoint set
						A_						:							Optional[Any]      = DisjointSetTree[T]()
						for node in self.connections:
								disjoint_set.make_set(lowercase   )

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







import sys
import turtle




def 							UpperCamelCase		(			__lowercase		:					tuple[float, float]		,__lowercase		:					tuple[float, float]      ):
		'''simple docstring'''




		return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2




def 							UpperCamelCase		(			__lowercase		:					tuple[float, float]		,__lowercase		:					tuple[float, float]		,__lowercase		:					tuple[float, float]		,__lowercase		:					int		,):
		'''simple docstring'''




		my_pen.up()
		my_pen.goto(vertexa[0]		,vertexa[1]      )
		my_pen.down()
		my_pen.goto(vertexa[0]		,vertexa[1]      )
		my_pen.goto(vertexa[0]		,vertexa[1]      )
		my_pen.goto(vertexa[0]		,vertexa[1]      )

		if depth == 0:
				return

		triangle(__lowercase		,get_mid(__lowercase		,__lowercase      )		,get_mid(__lowercase		,__lowercase      )		,depth - 1      )
		triangle(__lowercase		,get_mid(__lowercase		,__lowercase      )		,get_mid(__lowercase		,__lowercase      )		,depth - 1      )
		triangle(__lowercase		,get_mid(__lowercase		,__lowercase      )		,get_mid(__lowercase		,__lowercase      )		,depth - 1      )


if __name__ == "__main__":
	if len(sys.argv) != 2:
		raise ValueError(
		    """Correct format for using this script: """
		    """python fractals.py <int:depth_for_fractal>"""
		)
	_UpperCAmelCase          =						turtle.Turtle()
	my_pen.ht()
	my_pen.speed(5)
	my_pen.pencolor("""red""")

	_UpperCAmelCase          =						[(-175, -125), (0, 175), (175, -125)]  # vertices of triangle
	triangle(vertices[0], vertices[1], vertices[2], int(sys.argv[1]))






