





'''simple docstring'''






from __future__ import annotations


def 					_a   (__SCREAMING_SNAKE_CASE  ,      __SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  print(f'''Vertex\tShortest Distance from vertex {src}'''   )
  for i, d in enumerate(__SCREAMING_SNAKE_CASE   ):
    print(f'''{i}\t\t{d}'''   )


def 					_a   (__SCREAMING_SNAKE_CASE  ,      __SCREAMING_SNAKE_CASE  ,      __SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  for j in range(__SCREAMING_SNAKE_CASE   ):
    _UpperCamelCase			,     _UpperCamelCase			,     _UpperCamelCase       			=(graph[j][k] for k in ['''src''', '''dst''', '''weight'''])
    if distance[u] != float('''inf'''   ) and distance[u] + w < distance[v]:
      return True
  return False


def 					_a   (__SCREAMING_SNAKE_CASE  ,      __SCREAMING_SNAKE_CASE  ,      __SCREAMING_SNAKE_CASE  ,      __SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  _UpperCamelCase       			=[float('''inf'''   )] * vertex_count
  _UpperCamelCase       			=0.0

  for _ in range(vertex_count - 1   ):
    for j in range(__SCREAMING_SNAKE_CASE   ):
      _UpperCamelCase			,     _UpperCamelCase			,     _UpperCamelCase       			=(graph[j][k] for k in ['''src''', '''dst''', '''weight'''])

      if distance[u] != float('''inf'''   ) and distance[u] + w < distance[v]:
        _UpperCamelCase       			=distance[u] + w

  _UpperCamelCase       			=check_negative_cycle(__SCREAMING_SNAKE_CASE  ,      __SCREAMING_SNAKE_CASE  ,      __SCREAMING_SNAKE_CASE   )
  if negative_cycle_exists:
    raise Exception('''Negative cycle found'''   )

  return distance


if __name__ == "__main__":
      import doctest

      doctest.testmod()

      __lowerCamelCase						: Optional[int]		=   int(input('Enter number of vertices: ').strip())
      __lowerCamelCase						: Dict		=   int(input('Enter number of edges: ').strip())

      __lowerCamelCase						: list[dict[str, int]]		=   [{} for _ in range(E)]

      for i in range(E):
            print('Edge ', i + 1)
            __lowerCamelCase		, __lowerCamelCase		, __lowerCamelCase						: int		=   (
                int(x)
                for x in input('Enter source, destination, weight: ').strip().split(' ')
            )
            __lowerCamelCase						: Optional[Any]		=   {'src': src, 'dst': dest, 'weight': weight}

      __lowerCamelCase						: Dict		=   int(input('\nEnter shortest path source:').strip())
      __lowerCamelCase						: Optional[Any]		=   bellman_ford(graph, V, E, source)
      print_distance(shortest_distance, 0)













'''simple docstring'''






def 					_a   (__SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  return 1 if digit in (0, 1) else (digit * factorial(digit - 1   ))


def 					_a   (__SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  _UpperCamelCase       			=0
  _UpperCamelCase       			=number
  while duplicate > 0:
    _UpperCamelCase			,     _UpperCamelCase       			=divmod(__SCREAMING_SNAKE_CASE  ,      10   )
    fact_sum += factorial(__SCREAMING_SNAKE_CASE   )
  return fact_sum == number


if __name__ == "__main__":
      print('Program to check whether a number is a Krisnamurthy Number or not.')
      __lowerCamelCase						: Optional[Any]		=   int(input('Enter number: ').strip())
      print(
          F"""{number} is {'' if krishnamurthy(number) else 'not '}a Krishnamurthy Number."""
      )






