'''simple docstring'''


def    _lowerCamelCase       ( lowerCamelCase_   :				List[str]      ,	lowerCamelCase_   :				Union[str, Any]  ):



     """simple docstring"""





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


def    _lowerCamelCase       ( lowerCamelCase_   :				Union[str, Any]      ,	lowerCamelCase_   :				int      ,	lowerCamelCase_   :				str  ):



     """simple docstring"""





     UpperCAmelCase_				:  Dict  = float('inf'  )
     UpperCAmelCase_				:  Tuple  = -1
     for i in range(lowerCamelCase_  ):
          if (not vset[i]) and mdist[i] < min_val:
               UpperCAmelCase_				:  int  = i
               UpperCAmelCase_				:  Optional[Any]  = mdist[i]
     return min_ind


def    _lowerCamelCase       ( lowerCamelCase_   :				int      ,	lowerCamelCase_   :				Optional[Any]      ,	lowerCamelCase_   :				Any  ):



     """simple docstring"""





     UpperCAmelCase_				:  str  = [float('inf'  ) for _ in range(lowerCamelCase_  )]
     UpperCAmelCase_				:  Union[str, Any]  = [False for _ in range(lowerCamelCase_  )]
     UpperCAmelCase_				:  Optional[Any]  = 0.0

     for _ in range(v - 1  ):
          UpperCAmelCase_				:  Tuple  = min_dist(lowerCamelCase_      ,	lowerCamelCase_      ,	lowerCamelCase_  )
          UpperCAmelCase_				:  Dict  = True

          for i in range(lowerCamelCase_  ):
               if (
                   (not vset[i])
                   and graph[u][i] != float('inf'  )
                   and mdist[u] + graph[u][i] < mdist[i]
               ):
                    UpperCAmelCase_				:  Any  = mdist[u] + graph[u][i]

     print_dist(lowerCamelCase_      ,	lowerCamelCase_  )


if __name__ == "__main__":
 snake_case__	:     Union[str, Any]      =    int(input('''Enter number of vertices: ''').strip())
 snake_case__	:     Any      =    int(input('''Enter number of edges: ''').strip())

 snake_case__	:     Optional[int]      =    [[float('''inf''') for i in range(V)] for j in range(V)]

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

 for i in range(E):
  print('''\nEdge ''', i + 1)
  snake_case__	:     List[str]      =    int(input('''Enter source:''').strip())
  snake_case__	:     Dict      =    int(input('''Enter destination:''').strip())
  snake_case__	:     List[Any]      =    float(input('''Enter weight:''').strip())
  snake_case__	:     List[Any]      =    weight

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









"""simple docstring"""






from manim import *
class 	_lowerCAmelCase    (      __snake_case       ):

							def 					_lowerCAmelCase  ( self       :    Dict    )   ->    Tuple:

									"""simple docstring"""
									lowercase										=							Rectangle(height=0.5 ,		width=0.5    )
									lowercase										=							Rectangle(height=0.46 ,		width=0.46    ).set_stroke(width=0    )
									lowercase										=							Rectangle(height=0.25 ,		width=0.25    )

									lowercase										=							[mem.copy() for i in range(6    )]
									lowercase										=							[mem.copy() for i in range(6    )]
									lowercase										=							VGroup(*a    ).arrange(a ,		buff=0    )
									lowercase										=							VGroup(*a    ).arrange(a ,		buff=0    )
									lowercase										=							VGroup(a ,		a    ).arrange(a ,		buff=0    )
									lowercase										=							Text('''CPU''' ,		font_size=24    )
									lowercase										=							Group(a ,		a    ).arrange(a ,		buff=0.5 ,		aligned_edge=a    )
									cpu.move_to([-2.5, -0.5, 0]    )
									self.add(a    )

									lowercase										=							[mem.copy() for i in range(4    )]
									lowercase										=							VGroup(*a    ).arrange(a ,		buff=0    )
									lowercase										=							Text('''GPU''' ,		font_size=24    )
									lowercase										=							Group(a ,		a    ).arrange(a ,		buff=0.5 ,		aligned_edge=a    )
									gpu.move_to([-1, -1, 0]    )
									self.add(a    )

									lowercase										=							[mem.copy() for i in range(6    )]
									lowercase										=							VGroup(*a    ).arrange(a ,		buff=0    )

									lowercase										=							Text('''Model''' ,		font_size=24    )
									lowercase										=							Group(a ,		a    ).arrange(a ,		buff=0.5 ,		aligned_edge=a    )
									model.move_to([3, -1.0, 0]    )
									self.add(a    )

									lowercase										=							[]
									lowercase										=							[]

									for i, rect in enumerate(a    ):
											rect.set_stroke(a    )

											lowercase										=							Rectangle(height=0.46 / 4 ,		width=0.46 / 3    ).set_stroke(width=0.0    ).set_fill(a ,		opacity=0.7    )

											if i == 0:
													cpu_target.next_to(cpu_left_col_base[0].get_corner(DOWN + LEFT    ) ,		buff=0.02 ,		direction=a    )
													cpu_target.set_x(cpu_target.get_x() + 0.1    )
											elif i == 3:
													cpu_target.next_to(model_cpu_arr[0] ,		direction=a ,		buff=0.0    )
											else:
													cpu_target.next_to(model_cpu_arr[i - 1] ,		direction=a ,		buff=0.0    )
											self.add(a    )
											model_cpu_arr.append(a    )

									self.add(*a ,		*a    )

									lowercase										=							[meta_mem.copy() for i in range(6    )]
									lowercase										=							[meta_mem.copy() for i in range(6    )]
									lowercase										=							VGroup(*a    ).arrange(a ,		buff=0    )
									lowercase										=							VGroup(*a    ).arrange(a ,		buff=0    )
									lowercase										=							VGroup(a ,		a    ).arrange(a ,		buff=0    )
									lowercase										=							Text('''Disk''' ,		font_size=24    )
									lowercase										=							Group(a ,		a    ).arrange(a ,		buff=0.5 ,		aligned_edge=a    )
									disk.move_to([-4.0, -1.25, 0]    )
									self.add(a ,		a    )

									lowercase										=							[]

									for i in range(6    ):
											lowercase										=							fill.copy().set_fill(a ,		opacity=0.8    )
											target.move_to(disk_left_col_base[i]    ).scale(0.5    )
											cpu_disk_arr.append(a    )

									self.add(*a    )

									lowercase										=							Square(side_length=2.2    )
									key.move_to([-5, 2, 0]    )

									lowercase										=							MarkupText(
									    f"""<b>Key:</b>\n\n<span fgcolor='{YELLOW}'>●</span> Empty Model""" ,		font_size=18 ,		)

									key_text.move_to([-5, 2.4, 0]    )

									self.add(a ,		a    )

									lowercase										=							MarkupText(
									    f"""<span fgcolor='{BLUE}'>●</span> Checkpoint""" ,		font_size=18 ,		)

									blue_text.next_to(a ,		DOWN * 2.4 ,		aligned_edge=key_text.get_left()    )
									self.add(a    )

									lowercase										=							MarkupText(f"""The offloaded weights are all sent to the CPU.""" ,		font_size=24    )
									step_a.move_to([2, 2, 0]    )

									self.play(Write(a ,		run_time=3    )    )

									for i in range(6    ):
											lowercase										=							cpu_disk_arr[i]
											lowercase										=							rect.copy().set_fill(a ,		opacity=0.8    ).scale(2.0    )
											cpa.generate_target()
											cpa.target.move_to(model_base[i]    )

											if i == 0:
													rect.set_fill(a ,		opacity=0.8    )
													rect.generate_target()
													rect.target.move_to(cpu_left_col_base[0]    ).scale(2.0    )

													self.remove(
													    *a ,		*a ,		)

											else:
													rect.generate_target()
													rect.target.move_to(cpu_left_col_base[i]    ).scale(2.0    )
											self.play(MoveToTarget(a    ) ,		MoveToTarget(a    ) ,		model_base[i].animate.set_stroke(a    )    )
									self.play(FadeOut(a    )    )

									lowercase										=							MarkupText(
									    f"""Finally, hooks are added to each weight in the model\nto transfer the weights from CPU to GPU\n\t\tand back when needed.""" ,		font_size=24 ,		)
									step_a.move_to([2, 2, 0]    )

									self.play(Write(a ,		run_time=3    )    )

									lowercase										=							[]
									lowercase										=							[]
									for i in range(6    ):
											lowercase										=							Arrow(start=a ,		end=a ,		color=a ,		buff=0.5    )
											a.next_to(model_base[i].get_left() ,		a ,		buff=0.2    )
											arrows.append(a    )
											animations.append(Write(a    )    )
									self.play(*a    )
									self.wait()