





"""simple docstring"""
def  A__    (      UpperCamelCase ,  UpperCamelCase = 1_000	):
							if (not isinstance(UpperCamelCase ,  UpperCamelCase	)) or (digit_position <= 0):
														raise ValueError("Digit position must be a positive integer"	)
							elif (not isinstance(UpperCamelCase ,  UpperCamelCase	)) or (precision < 0):
														raise ValueError("Precision must be a nonnegative integer"	)

							# compute an approximation of (16 ** (n - 1)) * pi whose fractional part is mostly
							# accurate
							A		=  (
							    4 * _subsum(UpperCamelCase ,  1 ,  UpperCamelCase	)
							    - 2 * _subsum(UpperCamelCase ,  4 ,  UpperCamelCase	)
							    - _subsum(UpperCamelCase ,  5 ,  UpperCamelCase	)
							    - _subsum(UpperCamelCase ,  6 ,  UpperCamelCase	)
							)

							# return the first hex digit of the fractional part of the result
							return hex(int((sum_result % 1) * 16	)	)[2:]






def  A__    (      UpperCamelCase ,  UpperCamelCase ,  UpperCamelCase	):
							A		=  0.0
							for sum_index in range(digit_pos_to_extract + precision	):
														A		=  8 * sum_index + denominator_addend
														if sum_index < digit_pos_to_extract:
																					# if the exponential term is an integer and we mod it by the denominator
																					# before dividing, only the integer part of the sum will change;
																					# the fractional part will not
																					A		=  pow(
																					    16 ,  digit_pos_to_extract - 1 - sum_index ,  UpperCamelCase	)
														else:
																					A		=  pow(16 ,  digit_pos_to_extract - 1 - sum_index	)
														total += exponential_term / denominator
							return total


if __name__ == "__main__":
		import doctest

		doctest.testmod()









"""simple docstring"""
from __future__ import annotations






class  _UpperCAmelCase       :


					def __init__( self      :Optional[Any]					,	__UpperCamelCase      :int		):
												A		=  vertices
												A		=  [[0] * vertices for _ in range(__UpperCamelCase		)]


					def      lowerCamelCase	( self      :Optional[Any]					,	__UpperCamelCase      :list[int]		):
												print("Vertex \t Distance from Source"		)
												for vertex in range(self.vertices		):
																			print(__UpperCamelCase					,	"\t\t"					,	distances_from_source[vertex]		)


					def      lowerCamelCase	( self      :Union[str, Any]					,	__UpperCamelCase      :list[int]					,	__UpperCamelCase      :list[bool]		):
												A		=  1e7
												A		=  0

												# Search not nearest vertex not in the shortest path tree
												for vertex in range(self.vertices		):
																			if distances_from_source[vertex] < minimum and visited[vertex] is False:
																										A		=  distances_from_source[vertex]
																										A		=  vertex
												return min_index


					def      lowerCamelCase	( self      :List[Any]					,	__UpperCamelCase      :int		):
												A		=  [int(1e7		)] * self.vertices  # distances from the source
												A		=  0
												A		=  [False] * self.vertices

												for _ in range(self.vertices		):
																			A		=  self.minimum_distance(__UpperCamelCase					,	__UpperCamelCase		)
																			A		=  True

																			# Update dist value of the adjacent vertices
																			# of the picked vertex only if the current
																			# distance is greater than new distance and
																			# the vertex in not in the shortest path tree
																			for v in range(self.vertices		):
																										if (
																										    self.graph[u][v] > 0
																										    and visited[v] is False
																										    and distances[v] > distances[u] + self.graph[u][v]
																										):
																																	A		=  distances[u] + self.graph[u][v]

												self.print_solution(__UpperCamelCase		)


if __name__ == "__main__":
		_snake_case					:		List[Any]							=			Graph(9)
		_snake_case					:		List[str]							=			[
		    [0, 4, 0, 0, 0, 0, 0, 8, 0],
		    [4, 0, 8, 0, 0, 0, 0, 11, 0],
		    [0, 8, 0, 7, 0, 4, 0, 0, 2],
		    [0, 0, 7, 0, 9, 14, 0, 0, 0],
		    [0, 0, 0, 9, 0, 10, 0, 0, 0],
		    [0, 0, 4, 14, 10, 0, 2, 0, 0],
		    [0, 0, 0, 0, 0, 2, 0, 1, 6],
		    [8, 11, 0, 0, 0, 0, 1, 0, 7],
		    [0, 0, 2, 0, 0, 0, 6, 7, 0],
		]
		graph.dijkstra(0)


