

from __future__ import annotations

import requests







def 	_snake_case		(    SCREAMING_SNAKE_CASE				)       ->      dict:

     """simple docstring"""







     _lowerCAmelCase   :					Optional[int]        =    f'''https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty'''
     return requests.get(SCREAMING_SNAKE_CASE				).json()







def 	_snake_case		(    SCREAMING_SNAKE_CASE = 10				)       ->      list[dict]:

     """simple docstring"""







     _lowerCAmelCase   :					Optional[int]        =    "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty"
     _lowerCAmelCase   :					str        =    requests.get(SCREAMING_SNAKE_CASE				).json()[:max_stories]
     return [get_hackernews_story(SCREAMING_SNAKE_CASE				) for story_id in story_ids]







def 	_snake_case		(    SCREAMING_SNAKE_CASE = 10				)       ->      str:

     """simple docstring"""







     _lowerCAmelCase   :					str        =    hackernews_top_stories(SCREAMING_SNAKE_CASE				)
     return "\n".join("* [{title}]({url})".format(**SCREAMING_SNAKE_CASE				) for story in stories				)


if __name__ == "__main__":
  print(hackernews_top_stories_as_markdown())









from __future__ import annotations







def 	_snake_case		(    SCREAMING_SNAKE_CASE		,							SCREAMING_SNAKE_CASE				)       ->      List[Any]:

     """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 	_snake_case		(    SCREAMING_SNAKE_CASE		,							SCREAMING_SNAKE_CASE		,							SCREAMING_SNAKE_CASE				)       ->      Tuple:

     """simple docstring"""







     for j in range(SCREAMING_SNAKE_CASE				):
          _lowerCAmelCase      ,			_lowerCAmelCase      ,			_lowerCAmelCase   :					Any        =    (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 	_snake_case		(    SCREAMING_SNAKE_CASE		,							SCREAMING_SNAKE_CASE		,							SCREAMING_SNAKE_CASE		,							SCREAMING_SNAKE_CASE				)       ->      list[float]:

     """simple docstring"""







     _lowerCAmelCase   :					Tuple        =    [float("inf"				)] * vertex_count
     _lowerCAmelCase   :					int        =    0.0

     for _ in range(vertex_count - 1				):
          for j in range(SCREAMING_SNAKE_CASE				):
               _lowerCAmelCase      ,			_lowerCAmelCase      ,			_lowerCAmelCase   :					int        =    (graph[j][k] for k in ["src", "dst", "weight"])

               if distance[u] != float("inf"				) and distance[u] + w < distance[v]:
                    _lowerCAmelCase   :					List[str]        =    distance[u] + w

     _lowerCAmelCase   :					int        =    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()

  __UpperCAmelCase    				=     int(input('Enter number of vertices: ').strip())
  __UpperCAmelCase    				=     int(input('Enter number of edges: ').strip())

  __UpperCAmelCase    				=     [{} for _ in range(E)]

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

  __UpperCAmelCase    				=     int(input('\nEnter shortest path source:').strip())
  __UpperCAmelCase    				=     bellman_ford(graph, V, E, source)
  print_distance(shortest_distance, 0)






