



import timeit


class 	a__       :


					"""simple docstring"""



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



					def __mul__(		self     :Any      ,  lowercase__     :Any    ):
										lowercase						   =       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 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase				):
					"""simple docstring"""






					lowercase						   =       Matrix([[1, 0], [0, 1]]				)
					while b > 0:
										if b & 1:
															matrix *= a
										a *= a
										b >>= 1
					return matrix





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase				):
					"""simple docstring"""






					if n == 1:
										return fa
					elif n == 2:
										return fa
					lowercase						   =       Matrix([[1, 1], [1, 0]]				)
					lowercase						   =       modular_exponentiation(_UpperCAmelCase       ,			n - 2				)
					return fa * matrix.t[0][0] + fa * matrix.t[0][1]





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase				):
					"""simple docstring"""






					if n == 1:
										return fa
					elif n == 2:
										return fa

					lowercase						   =       fa
					lowercase						   =       fa
					n -= 2

					while n > 0:
										lowercase   ,      lowercase						   =       fn_a + fn_a, fn_a
										n -= 1

					return fn_a





def 		__snake_case						(    ):
					"""simple docstring"""






					lowercase						   =       '\nfrom random import randint\nfrom __main__ import fibonacci_with_matrix_exponentiation\n'
					lowercase						   =       'fibonacci_with_matrix_exponentiation(randint(1,70000), 1, 1)'
					lowercase						   =       timeit.timeit(setup=_UpperCAmelCase       ,			stmt=_UpperCAmelCase       ,			number=1_00				)
					print('With matrix exponentiation the average execution time is '       ,			exec_time / 1_00				)
					return exec_time





def 		__snake_case						(    ):
					"""simple docstring"""






					lowercase						   =       '\nfrom random import randint\nfrom __main__ import simple_fibonacci\n'
					lowercase						   =       'simple_fibonacci(randint(1,70000), 1, 1)'
					lowercase						   =       timeit.timeit(setup=_UpperCAmelCase       ,			stmt=_UpperCAmelCase       ,			number=1_00				)
					print(
					    'Without matrix exponentiation the average execution time is '       ,			exec_time / 1_00				)
					return exec_time





def 		__snake_case						(    ):
					"""simple docstring"""






					matrix_exponentiation_time()
					simple_fibonacci_time()


if __name__ == "__main__":
		main()











from __future__ import annotations

# Define the Gravitational Constant G and the function
__magic_name__       =     6.6743E-11  # unit of G : m^3 * kg^-1 * s^-2





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase				):
					"""simple docstring"""






					lowercase						   =       mass_a * mass_a

					if (force, mass_a, mass_a, distance).count(0				) != 1:
										raise ValueError('One and only one argument must be 0'				)
					if force < 0:
										raise ValueError('Gravitational force can not be negative'				)
					if distance < 0:
										raise ValueError('Distance can not be negative'				)
					if mass_a < 0 or mass_a < 0:
										raise ValueError('Mass can not be negative'				)
					if force == 0:
										lowercase						   =       GRAVITATIONAL_CONSTANT * product_of_mass / (distance**2)
										return {"force": force}
					elif mass_a == 0:
										lowercase						   =       (force) * (distance**2) / (GRAVITATIONAL_CONSTANT * mass_a)
										return {"mass_1": mass_a}
					elif mass_a == 0:
										lowercase						   =       (force) * (distance**2) / (GRAVITATIONAL_CONSTANT * mass_a)
										return {"mass_2": mass_a}
					elif distance == 0:
										lowercase						   =       (GRAVITATIONAL_CONSTANT * product_of_mass / (force)) ** 0.5
										return {"distance": distance}
					raise ValueError('One and only one argument must be 0'				)


# Run doctest
if __name__ == "__main__":
		import doctest

		doctest.testmod()






