
from __future__ import annotations

from collections.abc import Iterator
from typing import Any







class  _lowerCamelCase			:

     def __init__(  self							,       SCREAMING_SNAKE_CASE_    ):
            __snake_case						       =   data
            __snake_case						       =   None

     def __str__(  self    ):
            return f'''{self.data}'''







class  _lowerCamelCase			:

     def __init__(  self    ):
            __snake_case						       =   None
            __snake_case						       =   None

     def __iter__(  self    ):
            __snake_case						       =   self.front
            while node:
                   yield node.data
                   __snake_case						       =   node.next

     def __len__(  self    ):
            return len(tuple(iter(self    )    )    )

     def __str__(  self    ):
            return " <- ".join(str(SCREAMING_SNAKE_CASE_    ) for item in self    )

     def 						__lowerCamelCase				(  self    ):
            return len(self    ) == 0

     def 						__lowerCamelCase				(  self							,       SCREAMING_SNAKE_CASE_    ):
            __snake_case						       =   Node(SCREAMING_SNAKE_CASE_    )
            if self.is_empty():
                   __snake_case						       =   __snake_case						       =   node
            else:
                   assert isinstance(self.rear							,       SCREAMING_SNAKE_CASE_    )
                   __snake_case						       =   node
                   __snake_case						       =   node

     def 						__lowerCamelCase				(  self    ):
            if self.is_empty():
                   raise IndexError('dequeue from empty queue'    )
            assert isinstance(self.front							,       SCREAMING_SNAKE_CASE_    )
            __snake_case						       =   self.front
            __snake_case						       =   self.front.next
            if self.front is None:
                   __snake_case						       =   None
            return node.data

     def 						__lowerCamelCase				(  self    ):
            __snake_case						       =   __snake_case						       =   None


if __name__ == "__main__":
 from doctest import testmod

 testmod()





'''simple docstring'''



def 	__lowerCAmelCase       (				lowerCamelCase :    list[list[int]]					,		lowerCamelCase :    list[list[int]]       ):






	'''simple docstring'''




	__lowerCAmelCase       				=	[]
	__lowerCAmelCase       				=	len(lowerCamelCase       )
	for i in range(lowerCamelCase       ):
		__lowerCAmelCase       				=	[]
		for j in range(lowerCamelCase       ):
			__lowerCAmelCase       				=	0
			for k in range(lowerCamelCase       ):
				__lowerCAmelCase       				=	val + matrix_a[i][k] * matrix_b[k][j]
			list_a.append(lowerCamelCase       )
		matrix_c.append(lowerCamelCase       )
	return matrix_c



def 	__lowerCAmelCase       (				lowerCamelCase :    int       ):






	'''simple docstring'''




	return [[int(row == column       ) for column in range(lowerCamelCase       )] for row in range(lowerCamelCase       )]



def 	__lowerCAmelCase       (				lowerCamelCase :    int       ):






	'''simple docstring'''




	if n <= 1:
		return n
	__lowerCAmelCase       				=	identity(2       )
	__lowerCAmelCase       				=	[[1, 1], [1, 0]]
	__lowerCAmelCase       				=	n - 1
	while n > 0:
		if n % 2 == 1:
			__lowerCAmelCase       				=	multiply(lowerCamelCase					,		lowerCamelCase       )
		__lowerCAmelCase       				=	multiply(lowerCamelCase					,		lowerCamelCase       )
		__lowerCAmelCase       				=	int(n / 2       )
	return res_matrix[0][0]



def 	__lowerCAmelCase       (				lowerCamelCase :    int       ):






	'''simple docstring'''




	if n <= 1:
		return n
	__lowerCAmelCase       				=	0
	__lowerCAmelCase       				=	1
	for _ in range(2					,		n + 1       ):
		__lowerCAmelCase				,							__lowerCAmelCase       				=	fiba, fiba + fiba
	return fiba



def 	__lowerCAmelCase       (				):






	'''simple docstring'''




	for ordinal in "0th 1st 2nd 3rd 10th 100th 1000th".split():
		__lowerCAmelCase       				=	int("".join(c for c in ordinal if c in "0123456789"       )       )  # 1000th --> 1000
		print(
		    f'''{ordinal} fibonacci number using matrix exponentiation is '''
		    f'''{nth_fibonacci_matrix(lowerCamelCase       )} and using bruteforce is '''
		    f'''{nth_fibonacci_bruteforce(lowerCamelCase       )}\n'''       )
	# from timeit import timeit
	# print(timeit("nth_fibonacci_matrix(1000000)",
	#              "from main import nth_fibonacci_matrix", number=5))
	# print(timeit("nth_fibonacci_bruteforce(1000000)",
	#              "from main import nth_fibonacci_bruteforce", number=5))
	# 2.3342058970001744
	# 57.256506615000035


if __name__ == "__main__":
	import doctest

	doctest.testmod()
	main()