
from __future__ import annotations

from sys import maxsize
from typing import Generic, TypeVar

_lowerCamelCase	:    int          =      TypeVar('''T''')






def 	a_		(	__lowercase       :     int			)			->  int:
			return (position - 1) // 2






def 	a_		(	__lowercase       :     int			)			->  int:
			return (2 * position) + 1






def 	a_		(	__lowercase       :     int			)			->  int:
			return (2 * position) + 2




class        SCREAMING_SNAKE_CASE__					(     Generic[T] ):





	'''simple docstring'''



	def __init__(  self     :   Optional[Any]     ):


				'''simple docstring'''


				_snake_case          =      []
				_snake_case          =      {}
				_snake_case          =      0



	def __len__(  self     :   str     ):


				'''simple docstring'''


				return self.elements



	def __repr__(  self     :   Tuple     ):


				'''simple docstring'''


				return str(self.heap     )



	def 			A							(  self     :   Tuple     ):


				'''simple docstring'''


				return self.elements == 0



	def 			A							(  self     :   List[str]      ,  lowercase     :   T      ,  lowercase     :   int     ):


				'''simple docstring'''


				self.heap.append((elem, weight)     )
				_snake_case          =      self.elements
				self.elements += 1
				self._bubble_up(lowercase     )



	def 			A							(  self     :   List[str]     ):


				'''simple docstring'''


				if self.elements > 1:
							self._swap_nodes(0      ,  self.elements - 1     )
				_snake_case     , _snake_case          =      self.heap.pop()
				del self.position_map[elem]
				self.elements -= 1
				if self.elements > 0:
							_snake_case     , _snake_case          =      self.heap[0]
							self._bubble_down(lowercase     )
				return elem



	def 			A							(  self     :   Optional[Any]      ,  lowercase     :   T      ,  lowercase     :   int     ):


				'''simple docstring'''


				_snake_case          =      self.position_map[elem]
				_snake_case          =      (elem, weight)
				if position > 0:
							_snake_case          =      get_parent_position(lowercase     )
							_snake_case     , _snake_case          =      self.heap[parent_position]
							if parent_weight > weight:
										self._bubble_up(lowercase     )
							else:
										self._bubble_down(lowercase     )
				else:
							self._bubble_down(lowercase     )



	def 			A							(  self     :   Any      ,  lowercase     :   T     ):


				'''simple docstring'''


				_snake_case          =      self.position_map[elem]
				if curr_pos == 0:
							return None
				_snake_case          =      get_parent_position(lowercase     )
				_snake_case     , _snake_case          =      self.heap[curr_pos]
				_snake_case     , _snake_case          =      self.heap[parent_position]
				if parent_weight > weight:
							self._swap_nodes(lowercase      ,  lowercase     )
							return self._bubble_up(lowercase     )
				return None



	def 			A							(  self     :   Union[str, Any]      ,  lowercase     :   T     ):


				'''simple docstring'''


				_snake_case          =      self.position_map[elem]
				_snake_case     , _snake_case          =      self.heap[curr_pos]
				_snake_case          =      get_child_left_position(lowercase     )
				_snake_case          =      get_child_right_position(lowercase     )
				if child_left_position < self.elements and child_right_position < self.elements:
							_snake_case     , _snake_case          =      self.heap[child_left_position]
							_snake_case     , _snake_case          =      self.heap[child_right_position]
							if child_right_weight < child_left_weight and child_right_weight < weight:
										self._swap_nodes(lowercase      ,  lowercase     )
										return self._bubble_down(lowercase     )
				if child_left_position < self.elements:
							_snake_case     , _snake_case          =      self.heap[child_left_position]
							if child_left_weight < weight:
										self._swap_nodes(lowercase      ,  lowercase     )
										return self._bubble_down(lowercase     )
				else:
							return None
				if child_right_position < self.elements:
							_snake_case     , _snake_case          =      self.heap[child_right_position]
							if child_right_weight < weight:
										self._swap_nodes(lowercase      ,  lowercase     )
										return self._bubble_down(lowercase     )
				return None





	def 			A							(  self     :   List[Any]      ,  lowercase     :   int      ,  lowercase     :   int     ):


				'''simple docstring'''


				_snake_case          =      self.heap[nodea_pos][0]
				_snake_case          =      self.heap[nodea_pos][0]
				_snake_case     , _snake_case          =      (
				    self.heap[nodea_pos],
				    self.heap[nodea_pos],
				)
				_snake_case          =      nodea_pos
				_snake_case          =      nodea_pos




class        SCREAMING_SNAKE_CASE__					(     Generic[T] ):





	'''simple docstring'''



	def __init__(  self     :   Dict     ):


				'''simple docstring'''


				_snake_case          =      {}
				_snake_case          =      0



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


				'''simple docstring'''


				return str(self.connections     )



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


				'''simple docstring'''


				return self.nodes



	def 			A							(  self     :   Tuple      ,  lowercase     :   T     ):


				'''simple docstring'''


				if node not in self.connections:
							_snake_case          =      {}
							self.nodes += 1





	def 			A							(  self     :   Union[str, Any]      ,  lowercase     :   T      ,  lowercase     :   T      ,  lowercase     :   int     ):


				'''simple docstring'''


				self.add_node(lowercase     )
				self.add_node(lowercase     )
				_snake_case          =      weight
				_snake_case          =      weight






def 	a_		(	__lowercase       :     GraphUndirectedWeighted[T]	, )			->  tuple[dict[T, int], dict[T, T | None]]:
			_snake_case          =      {node: maxsize for node in graph.connections}
			_snake_case          =      {node: None for node in graph.connections}

			_snake_case          =      MinPriorityQueue()
			for node, weight in dist.items():
						priority_queue.push(__lowercase	, __lowercase			)

			if priority_queue.is_empty():
						return dist, parent

			# initialization
			_snake_case          =      priority_queue.extract_min()
			_snake_case          =      0
			for neighbour in graph.connections[node]:
						if dist[neighbour] > dist[node] + graph.connections[node][neighbour]:
									_snake_case          =      dist[node] + graph.connections[node][neighbour]
									priority_queue.update_key(__lowercase	, dist[neighbour]			)
									_snake_case          =      node

    # running prim's algorithm
			while not priority_queue.is_empty():
						_snake_case          =      priority_queue.extract_min()
						for neighbour in graph.connections[node]:
									if dist[neighbour] > dist[node] + graph.connections[node][neighbour]:
												_snake_case          =      dist[node] + graph.connections[node][neighbour]
												priority_queue.update_key(__lowercase	, dist[neighbour]			)
												_snake_case          =      node
			return dist, parent

def 	a_		(	__lowercase       :     List[Any]			)			->  Tuple:
			_snake_case          =      len(__lowercase			)
			for i in range(length - 1			):
						_snake_case          =      i
						for k in range(i + 1	, __lowercase			):
									if collection[k] < collection[least]:
												_snake_case          =      k
						if least != i:
									_snake_case     , _snake_case          =      (collection[i], collection[least])
			return collection


if __name__ == "__main__":
			_lowerCamelCase	:    str          =      input('''Enter numbers separated by a comma:\n''').strip()
			_lowerCamelCase	:    List[Any]          =      [int(item) for item in user_input.split(''',''')]
			print(selection_sort(unsorted))