






import timeit





class     __a						:







 def __init__(	self      :     Dict							,     SCREAMING_SNAKE_CASE      :     List[Any]		):


      '''simple docstring'''






      if isinstance(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE		):  # Initializes a matrix identical to the one provided.
           UpperCamelCase__    :     Optional[int]        =						arg
           UpperCamelCase__    :     Tuple        =						len(SCREAMING_SNAKE_CASE		)
      else:  # Initializes a square matrix of the given size and set values to zero.
           UpperCamelCase__    :     List[str]        =						arg
           UpperCamelCase__    :     Tuple        =						[[0 for _ in range(self.n		)] for _ in range(self.n		)]







 def __mul__(	self      :     str							,     SCREAMING_SNAKE_CASE      :     int		):


      '''simple docstring'''






      UpperCamelCase__    :     Tuple        =						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 	SCREAMING_SNAKE_CASE							(      __lowerCAmelCase      ,					__lowerCAmelCase    )				->			int:
     UpperCamelCase__    :     Union[str, Any]        =						Matrix([[1, 0], [0, 1]]    )
     while b > 0:
          if b & 1:
               matrix *= a
          a *= a
          b >>= 1
     return matrix







def 	SCREAMING_SNAKE_CASE							(      __lowerCAmelCase      ,					__lowerCAmelCase      ,					__lowerCAmelCase    )				->			str:
     # Trivial Cases
     if n == 1:
          return fa
     elif n == 2:
          return fa
     UpperCamelCase__    :     str        =						Matrix([[1, 1], [1, 0]]    )
     UpperCamelCase__    :     Dict        =						modular_exponentiation(__lowerCAmelCase      ,					n - 2    )
     return fa * matrix.t[0][0] + fa * matrix.t[0][1]







def 	SCREAMING_SNAKE_CASE							(      __lowerCAmelCase      ,					__lowerCAmelCase      ,					__lowerCAmelCase    )				->			Tuple:
     # Trivial Cases
     if n == 1:
          return fa
     elif n == 2:
          return fa

     UpperCamelCase__    :     Union[str, Any]        =						fa
     UpperCamelCase__    :     int        =						fa
     n -= 2

     while n > 0:
          UpperCamelCase__       ,  UpperCamelCase__    :     Any        =						fn_a + fn_a, fn_a
          n -= 1

     return fn_a







def 	SCREAMING_SNAKE_CASE							(      )				->			str:
     UpperCamelCase__    :     Any        =						"\nfrom random import randint\nfrom __main__ import fibonacci_with_matrix_exponentiation\n"
     UpperCamelCase__    :     Tuple        =						"fibonacci_with_matrix_exponentiation(randint(1,70000), 1, 1)"
     UpperCamelCase__    :     Any        =						timeit.timeit(setup=__lowerCAmelCase      ,					stmt=__lowerCAmelCase      ,					number=100    )
     print("With matrix exponentiation the average execution time is "      ,					exec_time / 100    )
     return exec_time







def 	SCREAMING_SNAKE_CASE							(      )				->			List[Any]:
     UpperCamelCase__    :     str        =						"\nfrom random import randint\nfrom __main__ import simple_fibonacci\n"
     UpperCamelCase__    :     str        =						"simple_fibonacci(randint(1,70000), 1, 1)"
     UpperCamelCase__    :     Union[str, Any]        =						timeit.timeit(setup=__lowerCAmelCase      ,					stmt=__lowerCAmelCase      ,					number=100    )
     print(
         "Without matrix exponentiation the average execution time is "      ,					exec_time / 100    )
     return exec_time







def 	SCREAMING_SNAKE_CASE							(      )				->			int:
     matrix_exponentiation_time()
     simple_fibonacci_time()


if __name__ == "__main__":
 main()







from __future__ import annotations

from collections.abc import Iterator
from typing import Any





class     __a						:







 def __init__(	self      :     str							,     SCREAMING_SNAKE_CASE      :     Any		):


      '''simple docstring'''






      UpperCamelCase__    :     Any        =						data
      UpperCamelCase__    :     Node | None        =						None







 def __str__(	self      :     Union[str, Any]		):


      '''simple docstring'''






      return F'{self.data}'







class     __a						:







 def __init__(	self      :     Optional[int]		):


      '''simple docstring'''






      UpperCamelCase__    :     Node | None        =						None
      UpperCamelCase__    :     Node | None        =						None







 def __iter__(	self      :     str		):


      '''simple docstring'''






      UpperCamelCase__    :     int        =						self.front
      while node:
           yield node.data
           UpperCamelCase__    :     Any        =						node.next







 def __len__(	self      :     Tuple		):


      '''simple docstring'''






      return len(tuple(iter(self		)		)		)







 def __str__(	self      :     Union[str, Any]		):


      '''simple docstring'''






      return " <- ".join(str(SCREAMING_SNAKE_CASE		) for item in self		)







 def       __lowercase      (	self      :     List[str]		):


      '''simple docstring'''






      return len(self		) == 0







 def       __lowercase      (	self      :     Union[str, Any]							,     SCREAMING_SNAKE_CASE      :     Any		):


      '''simple docstring'''






      UpperCamelCase__    :     int        =						Node(SCREAMING_SNAKE_CASE		)
      if self.is_empty():
           UpperCamelCase__    :     int        =						node
      else:
           assert isinstance(self.rear							,     SCREAMING_SNAKE_CASE		)
           UpperCamelCase__    :     Dict        =						node
           UpperCamelCase__    :     str        =						node







 def       __lowercase      (	self      :     Dict		):


      '''simple docstring'''






      if self.is_empty():
           raise IndexError("dequeue from empty queue"		)
      assert isinstance(self.front							,     SCREAMING_SNAKE_CASE		)
      UpperCamelCase__    :     Optional[int]        =						self.front
      UpperCamelCase__    :     List[str]        =						self.front.next
      if self.front is None:
           UpperCamelCase__    :     List[Any]        =						None
      return node.data







 def       __lowercase      (	self      :     str		):


      '''simple docstring'''






      UpperCamelCase__    :     Optional[int]        =						None


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

 testmod()