



import timeit



class 			_lowercase							:





	"""simple docstring"""




	def __init__(self	, lowerCamelCase_	):
						"""simple docstring"""

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




	def __mul__(self	, lowerCamelCase_	):
						"""simple docstring"""

						a        =     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 					a(   A :					Optional[int]				,  A :					Union[str, Any] )	-> List[str]:
					"""simple docstring"""





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






def 					a(   A :					List[Any]				,  A :					List[Any]				,  A :					Union[str, Any] )	-> str:
					"""simple docstring"""





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






def 					a(   A :					Tuple				,  A :					Dict				,  A :					Tuple )	-> int:
					"""simple docstring"""





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

					a        =     fa
					a        =     fa
					n -= 2

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

					return fn_a






def 					a(   )	-> Dict:
					"""simple docstring"""





					a        =     "\nfrom random import randint\nfrom __main__ import fibonacci_with_matrix_exponentiation\n"
					a        =     "fibonacci_with_matrix_exponentiation(randint(1,70000), 1, 1)"
					a        =     timeit.timeit(setup=A				,  stmt=A				,  number=100 )
					print("With matrix exponentiation the average execution time is "				,  exec_time / 100 )
					return exec_time






def 					a(   )	-> str:
					"""simple docstring"""





					a        =     "\nfrom random import randint\nfrom __main__ import simple_fibonacci\n"
					a        =     "simple_fibonacci(randint(1,70000), 1, 1)"
					a        =     timeit.timeit(setup=A				,  stmt=A				,  number=100 )
					print(
					    "Without matrix exponentiation the average execution time is "				,  exec_time / 100 )
					return exec_time






def 					a(   )	-> Tuple:
					"""simple docstring"""





					matrix_exponentiation_time()
					simple_fibonacci_time()


if __name__ == "__main__":
				main()





def 					a(   A :					Optional[Any]				,  A :					List[str] )	-> List[Any]:
					"""simple docstring"""





					print("\nVertex Distance" )
					for i in range(A ):
										if dist[i] != float("inf" ):
															print(A				,  "\t"				,  int(dist[i] )				,  end="\t" )
										else:
															print(A				,  "\t"				,  "INF"				,  end="\t" )
										print()






def 					a(   A :					str				,  A :					int				,  A :					int )	-> Optional[int]:
					"""simple docstring"""





					a        =     float("inf" )
					a        =     -1
					for i in range(A ):
										if (not vset[i]) and mdist[i] < min_val:
															a        =     i
															a        =     mdist[i]
					return min_ind






def 					a(   A :					List[str]				,  A :					Union[str, Any]				,  A :					Dict )	-> Tuple:
					"""simple docstring"""





					a        =     [float("inf" ) for _ in range(A )]
					a        =     [False for _ in range(A )]
					a        =     0.0

					for _ in range(v - 1 ):
										a        =     min_dist(A				,  A				,  A )
										a        =     True

										for i in range(A ):
															if (
															    (not vset[i])
															    and graph[u][i] != float("inf" )
															    and mdist[u] + graph[u][i] < mdist[i]
															):
																				a        =     mdist[u] + graph[u][i]

					print_dist(A				,  A )


if __name__ == "__main__":
				_lowercase:				Any       =	int(input("Enter number of vertices: ").strip())
				_lowercase:				Optional[Any]       =	int(input("Enter number of edges: ").strip())

				_lowercase:				List[str]       =	[[float("inf") for i in range(V)] for j in range(V)]

				for i in range(V):
								_lowercase:				List[Any]       =	0.0

				for i in range(E):
								print("\nEdge ", i + 1)
								_lowercase:				Tuple       =	int(input("Enter source:").strip())
								_lowercase:				Tuple       =	int(input("Enter destination:").strip())
								_lowercase:				int       =	float(input("Enter weight:").strip())
								_lowercase:				str       =	weight

				_lowercase:				Union[str, Any]       =	int(input("\nEnter shortest path source:").strip())
				dijkstra(graph, V, gsrc)
