"""simple docstring"""






import numpy as np



def   a_						( lowerCamelCase ,      lowerCamelCase="utf-8" ,      lowerCamelCase="surrogatepass"	):
				UpperCAmelCase__					=							bin(int.from_bytes(text.encode(lowerCamelCase ,      lowerCamelCase	) ,      'big'	)	)[2:]
				return bits.zfill(8 * ((len(lowerCamelCase	) + 7) // 8)	)



def   a_						( lowerCamelCase ,      lowerCamelCase="utf-8" ,      lowerCamelCase="surrogatepass"	):
				UpperCAmelCase__					=							int(lowerCamelCase ,      2	)
				return n.to_bytes((n.bit_length() + 7) // 8 ,      'big'	).decode(lowerCamelCase ,      lowerCamelCase	) or "\0"



def   a_						( lowerCamelCase ,      lowerCamelCase	):
				if size_par + len(lowerCamelCase	) <= 2**size_par - (len(lowerCamelCase	) - 1):
								raise ValueError('size of parity don\'t match with size of data'	)

				UpperCAmelCase__					=							[]
				UpperCAmelCase__					=							[]
				UpperCAmelCase__					=							[bin(lowerCamelCase	)[2:] for x in range(1 ,      size_par + len(lowerCamelCase	) + 1	)]

				# sorted information data for the size of the output data
				UpperCAmelCase__					=							[]
				# data position template + parity
				UpperCAmelCase__					=							[]
				# parity bit counter
				UpperCAmelCase__					=							0
				# counter position of data bits
				UpperCAmelCase__					=							0

				for x in range(1 ,      size_par + len(lowerCamelCase	) + 1	):
								# Performs a template of bit positions - who should be given,
								# and who should be parity
								if qtd_bp < size_par:
												if (np.log(lowerCamelCase	) / np.log(2	)).is_integer():
																data_out_gab.append('P'	)
																UpperCAmelCase__					=							qtd_bp + 1
												else:
																data_out_gab.append('D'	)
								else:
												data_out_gab.append('D'	)

								# Sorts the data to the new output size
								if data_out_gab[-1] == "D":
												data_ord.append(data[cont_data]	)
												cont_data += 1
								else:
												data_ord.append(lowerCamelCase	)

    # Calculates parity
				UpperCAmelCase__					=							0  # parity bit counter
				for bp in range(1 ,      size_par + 1	):
								# Bit counter one for a given parity
								UpperCAmelCase__					=							0
								# counter to control the loop reading
								UpperCAmelCase__					=							0
								for x in data_ord:
												if x is not None:
																try:
																				UpperCAmelCase__					=							(bin_pos[cont_loop])[-1 * (bp)]
																except IndexError:
																				UpperCAmelCase__					=							'0'
																if aux == "1" and x == "1":
																				cont_bo += 1
												cont_loop += 1
								parity.append(cont_bo % 2	)

								qtd_bp += 1

				# Mount the message
				UpperCAmelCase__					=							0  # parity bit counter
				for x in range(0 ,      size_par + len(lowerCamelCase	)	):
								if data_ord[x] is None:
												data_out.append(str(parity[cont_bp]	)	)
												cont_bp += 1
								else:
												data_out.append(data_ord[x]	)

				return data_out




def   a_						( lowerCamelCase ,      lowerCamelCase	):
				UpperCAmelCase__					=							[]
				# Parity bit counter
				UpperCAmelCase__					=							0
				# Counter p data bit reading
				UpperCAmelCase__					=							0
				# list of parity received
				UpperCAmelCase__					=							[]
				UpperCAmelCase__					=							[]

				for x in range(1 ,      len(lowerCamelCase	) + 1	):
								# Performs a template of bit positions - who should be given,
								#  and who should be parity
								if qtd_bp < size_par and (np.log(lowerCamelCase	) / np.log(2	)).is_integer():
												data_out_gab.append('P'	)
												UpperCAmelCase__					=							qtd_bp + 1
								else:
												data_out_gab.append('D'	)

								# Sorts the data to the new output size
								if data_out_gab[-1] == "D":
												data_output.append(data[cont_data]	)
								else:
												parity_received.append(data[cont_data]	)
								cont_data += 1

				# -----------calculates the parity with the data
				UpperCAmelCase__					=							[]
				UpperCAmelCase__					=							[]
				UpperCAmelCase__					=							[bin(lowerCamelCase	)[2:] for x in range(1 ,      size_par + len(lowerCamelCase	) + 1	)]

				#  sorted information data for the size of the output data
				UpperCAmelCase__					=							[]
				# Data position feedback + parity
				UpperCAmelCase__					=							[]
				# Parity bit counter
				UpperCAmelCase__					=							0
				# Counter p data bit reading
				UpperCAmelCase__					=							0

				for x in range(1 ,      size_par + len(lowerCamelCase	) + 1	):
								# Performs a template position of bits - who should be given,
								# and who should be parity
								if qtd_bp < size_par and (np.log(lowerCamelCase	) / np.log(2	)).is_integer():
												data_out_gab.append('P'	)
												UpperCAmelCase__					=							qtd_bp + 1
								else:
												data_out_gab.append('D'	)

								# Sorts the data to the new output size
								if data_out_gab[-1] == "D":
												data_ord.append(data_output[cont_data]	)
												cont_data += 1
								else:
												data_ord.append(lowerCamelCase	)

    # Calculates parity
				UpperCAmelCase__					=							0  # parity bit counter
				for bp in range(1 ,      size_par + 1	):
								# Bit counter one for a certain parity
								UpperCAmelCase__					=							0
								# Counter to control loop reading
								UpperCAmelCase__					=							0
								for x in data_ord:
												if x is not None:
																try:
																				UpperCAmelCase__					=							(bin_pos[cont_loop])[-1 * (bp)]
																except IndexError:
																				UpperCAmelCase__					=							'0'
																if aux == "1" and x == "1":
																				cont_bo += 1
												cont_loop += 1
								parity.append(str(cont_bo % 2	)	)

								qtd_bp += 1

				# Mount the message
				UpperCAmelCase__					=							0  # Parity bit counter
				for x in range(0 ,      size_par + len(lowerCamelCase	)	):
								if data_ord[x] is None:
												data_out.append(str(parity[cont_bp]	)	)
												cont_bp += 1
								else:
												data_out.append(data_ord[x]	)

				UpperCAmelCase__					=							parity_received == parity
				return data_output, ack




"""simple docstring"""






from __future__ import annotations
class     snake_case	:




					"""simple docstring"""

					def __init__(    self       :     Tuple   ,lowerCamelCase__       :     int      ):
									UpperCAmelCase__					=							vertices
									UpperCAmelCase__					=							[[0] * vertices for _ in range(lowerCamelCase__      )]







					def 		__lowerCAmelCase						(    self       :     Dict   ,lowerCamelCase__       :     list[int]      ):
									print('Vertex \t Distance from Source'      )
									for vertex in range(self.vertices      ):
													print(lowerCamelCase__   ,'\t\t'   ,distances_from_source[vertex]      )







					def 		__lowerCAmelCase						(    self       :     List[Any]   ,lowerCamelCase__       :     list[int]   ,lowerCamelCase__       :     list[bool]      ):
									UpperCAmelCase__					=							1e7
									UpperCAmelCase__					=							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:
																	UpperCAmelCase__					=							distances_from_source[vertex]
																	UpperCAmelCase__					=							vertex
									return min_index







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

									for _ in range(self.vertices      ):
													UpperCAmelCase__					=							self.minimum_distance(lowerCamelCase__   ,lowerCamelCase__      )
													UpperCAmelCase__					=							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]
																	):
																					UpperCAmelCase__					=							distances[u] + self.graph[u][v]

									self.print_solution(lowerCamelCase__      )


if __name__ == "__main__":
						lowerCAmelCase__  :  List[str]											=     Graph(9)
						lowerCAmelCase__  :  Tuple											=     [
						    [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)



