



class    __lowerCAmelCase					:




				def __init__(				self		,							_snake_case						):



									"""simple docstring"""





									_lowerCAmelCase         =       data
									_lowerCAmelCase         =       42
									_lowerCAmelCase         =       42


def 						_UpperCAmelCase							( snake_case     ):





					"""simple docstring"""

					_lowerCAmelCase         =       0
					_lowerCAmelCase         =       x


def 						_UpperCAmelCase							( snake_case      ,		snake_case     ):





					"""simple docstring"""

					_lowerCAmelCase      ,      _lowerCAmelCase         =       find_set(snake_case     ), find_set(snake_case     )
					if x == y:
										return

					elif x.rank > y.rank:
										_lowerCAmelCase         =       x
					else:
										_lowerCAmelCase         =       y
										if x.rank == y.rank:
															y.rank += 1


def 						_UpperCAmelCase							( snake_case     ):





					"""simple docstring"""

					if x != x.parent:
										_lowerCAmelCase         =       find_set(x.parent     )
					return x.parent


def 						_UpperCAmelCase							( snake_case     ):





					"""simple docstring"""

					_lowerCAmelCase         =       ({0, 1, 2}, {3, 4, 5})
					for s in sets:
										if node.data in s:
															return s
					_lowerCAmelCase         =       F'{node.data} is not in {sets}'
					raise ValueError(snake_case     )


def 						_UpperCAmelCase							( ):





					"""simple docstring"""

					_lowerCAmelCase         =       [Node(snake_case     ) for i in range(6     )]
					for v in vertex:
										make_set(snake_case     )

					union_set(vertex[0]      ,		vertex[1]     )
					union_set(vertex[1]      ,		vertex[2]     )
					union_set(vertex[3]      ,		vertex[4]     )
					union_set(vertex[3]      ,		vertex[5]     )

					for nodea in vertex:
										for nodea in vertex:
															if find_python_set(snake_case     ).isdisjoint(find_python_set(snake_case     )     ):
																				assert find_set(snake_case     ) != find_set(snake_case     )
															else:
																				assert find_set(snake_case     ) == find_set(snake_case     )


if __name__ == "__main__":
	test_disjoint_set()










'''simple docstring'''






import timeit


class 	_lowercase    :


   def __init__(			self     , _UpperCAmelCase       ):
       if isinstance(_UpperCAmelCase     , _UpperCAmelCase       ):  # Initializes a matrix identical to the one provided.
           A							:							List[Any]				=    arg
           A							:							Dict				=    len(_UpperCAmelCase       )
       else:  # Initializes a square matrix of the given size and set values to zero.
           A							:							str				=    arg
           A							:							Union[str, Any]				=    [[0 for _ in range(self.n       )] for _ in range(self.n       )]


   def __mul__(			self     , _UpperCAmelCase       ):
       A							:							List[str]				=    Matrix(self.n       )
       for i in range(self.n       ):
           for j in range(self.n       ):
               for k in range(self.n       ):
                   matrix.t[i][j] += self.t[i][k] * b.t[k][j]
       return matrix







def 				_lowerCamelCase(	UpperCamelCase__     :			Union[str, Any]     ,							UpperCamelCase__     :			int		)		->	Union[str, Any]:
    A							:							Tuple				=    Matrix([[1, 0], [0, 1]]		)
    while b > 0:
        if b & 1:
            matrix *= a
        a *= a
        b >>= 1
    return matrix
def 				_lowerCamelCase(	UpperCamelCase__     :			int     ,							UpperCamelCase__     :			Tuple     ,							UpperCamelCase__     :			Any		)		->	Any:
    # Trivial Cases
    if n == 1:
        return fa
    elif n == 2:
        return fa
    A							:							Optional[Any]				=    Matrix([[1, 1], [1, 0]]		)
    A							:							int				=    modular_exponentiation(UpperCamelCase__     ,							n - 2		)
    return fa * matrix.t[0][0] + fa * matrix.t[0][1]
def 				_lowerCamelCase(	UpperCamelCase__     :			str     ,							UpperCamelCase__     :			Optional[Any]     ,							UpperCamelCase__     :			Any		)		->	List[Any]:
    # Trivial Cases
    if n == 1:
        return fa
    elif n == 2:
        return fa

    A							:							str				=    fa
    A							:							List[Any]				=    fa
    n -= 2

    while n > 0:
        A,						A							:							List[str]				=    fn_a + fn_a, fn_a
        n -= 1

    return fn_a
def 				_lowerCamelCase(	)		->	Union[str, Any]:
    A							:							Any				=    '''
from random import randint
from __main__ import fibonacci_with_matrix_exponentiation
'''
    A							:							Optional[int]				=    '''fibonacci_with_matrix_exponentiation(randint(1,70000), 1, 1)'''
    A							:							List[Any]				=    timeit.timeit(setup=UpperCamelCase__     ,							stmt=UpperCamelCase__     ,							number=100		)
    print('''With matrix exponentiation the average execution time is '''     ,							exec_time / 100		)
    return exec_time
def 				_lowerCamelCase(	)		->	List[Any]:
    A							:							str				=    '''
from random import randint
from __main__ import simple_fibonacci
'''
    A							:							Any				=    '''simple_fibonacci(randint(1,70000), 1, 1)'''
    A							:							str				=    timeit.timeit(setup=UpperCamelCase__     ,							stmt=UpperCamelCase__     ,							number=100		)
    print(
        '''Without matrix exponentiation the average execution time is '''     ,							exec_time / 100		)
    return exec_time
def 				_lowerCamelCase(	)		->	Optional[Any]:
    matrix_exponentiation_time()
    simple_fibonacci_time()


if __name__ == "__main__":
     main()
