


'''simple docstring'''
class 						_lowerCamelCase					:




 '''simple docstring'''


 def __init__(      self						):

    """simple docstring"""







    __A  :		Any       =			0
    __A  :		Any       =			0
    __A  :		Any       =			{}


 def  snake_case__   (      self      ,      __lowercase						):

    """simple docstring"""







    if vertex not in self.adjacency:
       __A  :		Union[str, Any]       =			{}
       self.num_vertices += 1


 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase      ,      __lowercase						):

    """simple docstring"""







    self.add_vertex(_snake_case						)
    self.add_vertex(_snake_case						)

    if head == tail:
       return

    __A  :		List[Any]       =			weight
    __A  :		List[Any]       =			weight


 def  snake_case__   (      self						):

    """simple docstring"""







    __A  :		Optional[Any]       =			self.get_edges()
    for edge in edges:
       __A     ,__A     ,__A  :		List[Any]       =			edge
       edges.remove((tail, head, weight)						)
    for i in range(len(_snake_case						)						):
       __A  :		Dict       =			list(edges[i]						)

    edges.sort(key=lambda __lowercase						: e[2]						)
    for i in range(len(_snake_case						) - 1						):
       if edges[i][2] >= edges[i + 1][2]:
          __A  :		List[Any]       =			edges[i][2] + 1
    for edge in edges:
       __A     ,__A     ,__A  :		Any       =			edge
       __A  :		Optional[Any]       =			weight
       __A  :		int       =			weight


 def __str__(      self						):

    """simple docstring"""







    __A  :		Optional[int]       =			''
    for tail in self.adjacency:
       for head in self.adjacency[tail]:
          __A  :		Any       =			self.adjacency[head][tail]
          string += F"""{head} -> {tail} == {weight}\n"""
    return string.rstrip('\n'						)


 def  snake_case__   (      self						):

    """simple docstring"""







    __A  :		Tuple       =			[]
    for tail in self.adjacency:
       for head in self.adjacency[tail]:
          output.append((tail, head, self.adjacency[head][tail])						)
    return output


 def  snake_case__   (      self						):

    """simple docstring"""







    return self.adjacency.keys()


 @staticmethod
 def  snake_case__   (      __lowercase=None      ,      __lowercase=None						):

    """simple docstring"""







    __A  :		List[str]       =			Graph()
    if vertices is None:
       __A  :		Dict       =			[]
    if edges is None:
       __A  :		Dict       =			[]
    for vertex in vertices:
       g.add_vertex(_snake_case						)
    for edge in edges:
       g.add_edge(*_snake_case						)
    return g

 class 						_lowerCamelCase					:




  '''simple docstring'''


  def __init__(      self						):

     """simple docstring"""







     __A  :		List[str]       =			{}
     __A  :		List[str]       =			{}


  def __len__(      self						):

     """simple docstring"""







     return len(self.parent						)


  def  snake_case__   (      self      ,      __lowercase						):

     """simple docstring"""







     if item in self.parent:
        return self.find(_snake_case						)

     __A  :		List[Any]       =			item
     __A  :		Optional[Any]       =			0
     return item


  def  snake_case__   (      self      ,      __lowercase						):

     """simple docstring"""







     if item not in self.parent:
        return self.make_set(_snake_case						)
     if item != self.parent[item]:
        __A  :		int       =			self.find(self.parent[item]						)
     return self.parent[item]







  def  snake_case__   (      self      ,      __lowercase      ,      __lowercase						):

     """simple docstring"""







     __A  :		Optional[int]       =			self.find(_snake_case						)
     __A  :		Any       =			self.find(_snake_case						)

     if roota == roota:
        return roota

     if self.rank[roota] > self.rank[roota]:
        __A  :		Any       =			roota
        return roota

     if self.rank[roota] < self.rank[roota]:
        __A  :		Union[str, Any]       =			roota
        return roota

     if self.rank[roota] == self.rank[roota]:
        self.rank[roota] += 1
        __A  :		Any       =			roota
        return roota
     return None


 @staticmethod
 def  snake_case__   (      __lowercase						):

    """simple docstring"""







    __A  :		Union[str, Any]       =			graph.num_vertices

    __A  :		int       =			Graph.UnionFind()
    __A  :		List[Any]       =			[]
    while num_components > 1:
       __A  :		Optional[Any]       =			{}
       for vertex in graph.get_vertices():
          __A  :		str       =			-1

       __A  :		Dict       =			graph.get_edges()
       for edge in edges:
          __A     ,__A     ,__A  :		Optional[int]       =			edge
          edges.remove((tail, head, weight)						)
       for edge in edges:
          __A     ,__A     ,__A  :		Tuple       =			edge
          __A  :		Optional[int]       =			union_find.find(_snake_case						)
          __A  :		List[Any]       =			union_find.find(_snake_case						)
          if seta != seta:
             if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
                __A  :		str       =			[head, tail, weight]

             if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
                __A  :		Dict       =			[head, tail, weight]
       for vertex in cheap_edge:
          if cheap_edge[vertex] != -1:
             __A     ,__A     ,__A  :		Tuple       =			cheap_edge[vertex]
             if union_find.find(_snake_case						) != union_find.find(_snake_case						):
                union_find.union(_snake_case      ,      _snake_case						)
                mst_edges.append(cheap_edge[vertex]						)
                __A  :		Union[str, Any]       =			num_components - 1
    __A  :		List[str]       =			Graph.build(edges=_snake_case						)
    return mst










'''simple docstring'''
from __future__ import annotations


def 			_lowercase       (				UpperCamelCase__       :					list,				UpperCamelCase__       :					int,				UpperCamelCase__       :					int,				UpperCamelCase__       :					int			):
 __A  :		Dict       =			[]
 __A     ,__A  :		Dict       =			input_list[low:mid], input_list[mid : high + 1]
 while left and right:
  result.append((left if left[0] <= right[0] else right).pop(0			)			)
 __A  :		Optional[Any]       =			result + left + right
 return input_list


def 			_lowercase       (				UpperCamelCase__       :					list			):
 if len(UpperCamelCase__			) <= 1:
  return input_list
 __A  :		Any       =			list(UpperCamelCase__			)

 # iteration for two-way merging
 __A  :		Dict       =			2
 while p <= len(UpperCamelCase__			):
  # getting low, high and middle value for merge-sort of single list
  for i in range(0,				len(UpperCamelCase__			),				UpperCamelCase__			):
   __A  :		Union[str, Any]       =			i
   __A  :		Tuple       =			i + p - 1
   __A  :		Union[str, Any]       =			(low + high + 1) // 2
   __A  :		Tuple       =			merge(UpperCamelCase__,				UpperCamelCase__,				UpperCamelCase__,				UpperCamelCase__			)
  # final merge of last two parts
  if p * 2 >= len(UpperCamelCase__			):
   __A  :		Optional[int]       =			i
   __A  :		str       =			merge(UpperCamelCase__,				0,				UpperCamelCase__,				len(UpperCamelCase__			) - 1			)
   break
  p *= 2

 return input_list


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






