






"""simple docstring"""




import webbrowser
from sys import argv
from urllib.parse import parse_qs, quote

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

if __name__ == "__main__":
 _snake_case          =   '%20'.join(argv[1:]) if len(argv) > 1 else quote(str(input('Search: ')))

 print('Googling.....')

 _snake_case          =   F'''https://www.google.com/search?q={query}&num=100'''

 _snake_case          =   requests.get(
     url,
     headers={'User-Agent': str(UserAgent().random)},
 )

 try:
  _snake_case          =   (
      BeautifulSoup(res.text, 'html.parser')
      .find('div', attrs={'class': 'yuRUbf'})
      .find('a')
      .get('href')
  )

 except AttributeError:
  _snake_case          =   parse_qs(
      BeautifulSoup(res.text, 'html.parser')
      .find('div', attrs={'class': 'kCrYT'})
      .find('a')
      .get('href')
  )['url'][0]

 webbrowser.open(link)









"""simple docstring"""




from __future__ import annotations

def 			lowerCAmelCase__     (     UpperCamelCase__     ,   UpperCamelCase__				):



  '''simple docstring'''
  print(F"""Vertex\tShortest Distance from vertex {src}"""				)
  for i, d in enumerate(UpperCamelCase__				):
    print(F"""{i}\t\t{d}"""				)

def 			lowerCAmelCase__     (     UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__				):



  '''simple docstring'''
  for j in range(UpperCamelCase__				):
    _a      ,  _a      ,  _a  :       List[str]             =	(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 			lowerCAmelCase__     (     UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__				):



  '''simple docstring'''
  _a  :       Dict             =	[float("""inf"""				)] * vertex_count
  _a  :       Any             =	0.0

  for _ in range(vertex_count - 1				):
    for j in range(UpperCamelCase__				):
      _a      ,  _a      ,  _a  :       List[Any]             =	(graph[j][k] for k in ["""src""", """dst""", """weight"""])

      if distance[u] != float("""inf"""				) and distance[u] + w < distance[v]:
        _a  :       Any             =	distance[u] + w

  _a  :       Union[str, Any]             =	check_negative_cycle(UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__				)
  if negative_cycle_exists:
    raise Exception("""Negative cycle found"""				)

  return distance


if __name__ == "__main__":
 import doctest

 doctest.testmod()

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

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

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

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

