


"""simple docstring"""





from __future__ import annotations

from typing import Generic, TypeVar

snake_case__		:     Optional[Any]    				=				TypeVar('''T''')



class 		snake_case_(       Generic[T]			):






     def __init__(	self  :					Optional[Any]					,				UpperCamelCase_  :					T				):
           lowerCAmelCase					:	Dict       =   data
           lowerCAmelCase					:	Union[str, Any]       =   self
           lowerCAmelCase					:	Tuple       =   0



class 		snake_case_(       Generic[T]			):






     def __init__(	self  :					Optional[int]				):
           # map from node name to the node object
           lowerCAmelCase					:	dict[T, DisjointSetTreeNode[T]]       =   {}






     def      lowerCamelCase__     (	self  :					Union[str, Any]					,				UpperCamelCase_  :					T				):
           # create a new set with x as its member
           lowerCAmelCase					:	Optional[int]       =   DisjointSetTreeNode(UpperCamelCase_				)






     def      lowerCamelCase__     (	self  :					Optional[Any]					,				UpperCamelCase_  :					T				):
           # find the set x belongs to (with path-compression)
           lowerCAmelCase					:	Tuple       =   self.map[data]
           if elem_ref != elem_ref.parent:
                 lowerCAmelCase					:	Tuple       =   self.find_set(elem_ref.parent.data				)
           return elem_ref.parent






     def      lowerCamelCase__     (	self  :					Union[str, Any]					,				UpperCamelCase_  :					DisjointSetTreeNode[T]					,				UpperCamelCase_  :					DisjointSetTreeNode[T]				):
           # helper function for union operation
           if nodea.rank > nodea.rank:
                 lowerCAmelCase					:	Union[str, Any]       =   nodea
           else:
                 lowerCAmelCase					:	Optional[int]       =   nodea
                 if nodea.rank == nodea.rank:
                       nodea.rank += 1






     def      lowerCamelCase__     (	self  :					List[str]					,				UpperCamelCase_  :					T					,				UpperCamelCase_  :					T				):
           # merge 2 disjoint sets
           self.link(self.find_set(UpperCamelCase_				)					,				self.find_set(UpperCamelCase_				)				)



class 		snake_case_(       Generic[T]			):






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






     def      lowerCamelCase__     (	self  :					Union[str, Any]					,				UpperCamelCase_  :					T				):
           # add a node ONLY if its not present in the graph
           if node not in self.connections:
                 lowerCAmelCase					:	Any       =   {}






     def      lowerCamelCase__     (	self  :					List[str]					,				UpperCamelCase_  :					T					,				UpperCamelCase_  :					T					,				UpperCamelCase_  :					int				):
           # add an edge with the given weight
           self.add_node(UpperCamelCase_				)
           self.add_node(UpperCamelCase_				)
           lowerCAmelCase					:	Tuple       =   weight
           lowerCAmelCase					:	List[str]       =   weight






     def      lowerCamelCase__     (	self  :					Optional[Any]				):
           lowerCAmelCase					:	Union[str, Any]       =   []
           lowerCAmelCase					:	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 UpperCamelCase_				: x[2]				)

           # creating the disjoint set
           lowerCAmelCase					:	List[str]       =   DisjointSetTree[T]()
           for node in self.connections:
                 disjoint_set.make_set(UpperCamelCase_				)

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






"""simple docstring"""





def      _snake_case						(						_snake_case				:			int ,   _snake_case				:			int			):
      return base * power(_snake_case ,   (exponent - 1)			) if exponent else 1


if __name__ == "__main__":
 print('''Raise base to the power of exponent using recursion...''')
 snake_case__		:     Union[str, Any]    				=				int(input('''Enter the base: ''').strip())
 snake_case__		:     Optional[Any]    				=				int(input('''Enter the exponent: ''').strip())
 snake_case__		:     Any    				=				power(base, abs(exponent))
 if exponent < 0:  # power() does not properly deal w/ negative exponents
  snake_case__		:     Dict    				=				1 / result
 print(f"""{base} to the power of {exponent} is {result}""")


