code: 
  
  
  from collections import deque
  
  
  
  
  def       a__						(		snake_case__				:       Optional[int]    ):
    return input(snake_case__    ).strip().split(""" """    )
  
  
  
  
  def       a__						(		snake_case__				:       int	,      snake_case__				:       int    ):
    _UpperCAmelCase		:       dict[int, list[int]]       =    {}
    for i in range(snake_case__    ):
      _UpperCAmelCase		:       Union[str, Any]       =    []
  
    for e in range(snake_case__    ):
      _UpperCAmelCase,_UpperCAmelCase		:       List[Any]       =    (int(snake_case__    ) for i in _input(f'''Edge {e + 1}: <node1> <node2> '''    ))
      graph[x].append(snake_case__    )
    return graph
  
  
  
  
  def       a__						(		snake_case__				:       int	,      snake_case__				:       int    ):
    _UpperCAmelCase		:       dict[int, list[int]]       =    {}
    for i in range(snake_case__    ):
      _UpperCAmelCase		:       Union[str, Any]       =    []
  
    for e in range(snake_case__    ):
      _UpperCAmelCase,_UpperCAmelCase		:       List[Any]       =    (int(snake_case__    ) for i in _input(f'''Edge {e + 1}: <node1> <node2> '''    ))
      graph[x].append(snake_case__    )
      graph[y].append(snake_case__    )
    return graph
  
  
  
  
  def       a__						(		snake_case__				:       int	,      snake_case__				:       int    ):
    _UpperCAmelCase		:       dict[int, list[tuple[int, int]]]       =    {}
    for i in range(snake_case__    ):
      _UpperCAmelCase		:       int       =    []
  
    for e in range(snake_case__    ):
      _UpperCAmelCase,_UpperCAmelCase,_UpperCAmelCase		:       Union[str, Any]       =    (int(snake_case__    ) for i in _input(f'''Edge {e + 1}: <node1> <node2> <weight> '''    ))
      graph[x].append((y, w)    )
      graph[y].append((x, w)    )
    return graph
  
  
  if __name__ == "__main__":
   SCREAMING_SNAKE_CASE__     ,				SCREAMING_SNAKE_CASE__				:    Dict         =    (int(i) for i in _input('Number of nodes and edges: '))
  
   SCREAMING_SNAKE_CASE__				:    Union[str, Any]         =    int(
       _input(
           'Press 1 or 2 or 3 \n'
           '1. Unweighted directed \n'
           '2. Unweighted undirected \n'
           '3. Weighted undirected \n'
       )[0]
   )
  
   SCREAMING_SNAKE_CASE__				:    Optional[int]         =    {
       1: initialize_unweighted_directed_graph,
       2: initialize_unweighted_undirected_graph,
       3: initialize_weighted_undirected_graph,
   }[graph_choice](n, m)
  
  
  
  
  def       a__						(		snake_case__				:       Optional[int]	,      snake_case__				:       Optional[Any]    ):
    _UpperCAmelCase,_UpperCAmelCase		:       List[str]       =    {s}, [s]
    print(snake_case__    )
    while _s:
      _UpperCAmelCase		:       int       =    0
      for i in g[_s[-1]]:
        if i not in vis:
          _s.append(snake_case__    )
          vis.add(snake_case__    )
          _UpperCAmelCase		:       Optional[Any]       =    1
          print(snake_case__    )
          break
      if not flag:
        _s.pop()
  
  
  
  
  def       a__						(		snake_case__				:       List[Any]	,      snake_case__				:       List[Any]    ):
    _UpperCAmelCase,_UpperCAmelCase		:       Optional[Any]       =    {s}, deque([s]    )
    print(snake_case__    )
    while q:
      _UpperCAmelCase		:       Dict       =    q.popleft()
      for v in g[u]:
        if v not in vis:
          vis.add(snake_case__    )
          q.append(snake_case__    )
          print(snake_case__    )
  
  
  
  
  def       a__						(		snake_case__				:       Optional[int]	,      snake_case__				:       str    ):
    _UpperCAmelCase,_UpperCAmelCase,_UpperCAmelCase		:       str       =    {s: 0}, set(), {s: 0}
    while True:
      if len(snake_case__    ) == len(snake_case__    ) - 1:
        break
      _UpperCAmelCase		:       int       =    10_0000
      for i in dist:
        if i not in known and dist[i] < mini:
          _UpperCAmelCase		:       Optional[Any]       =    dist[i]
          _UpperCAmelCase		:       Dict       =    i
      known.add(snake_case__    )
      for v in g[u]:
        if v[0] not in known and dist[u] + v[1] < dist.get(v[0]	,      10_0000    ):
          _UpperCAmelCase		:       Optional[int]       =    dist[u] + v[1]
          _UpperCAmelCase		:       int       =    u
    for i in dist:
      if i != s:
        print(dist[i]    )
  
  
  
  
  def       a__						(		snake_case__				:       List[Any]	,      snake_case__				:       Any=None	,      snake_case__				:       List[Any]=None    ):
    if q is None:
      _UpperCAmelCase		:       int       =    [1]
    if ind is None:
      _UpperCAmelCase		:       Dict       =    [0] * (len(snake_case__    ) + 1)  # SInce oth Index is ignored
      for u in g:
        for v in g[u]:
          ind[v] += 1
      _UpperCAmelCase		:       Union[str, Any]       =    deque()
      for i in g:
        if ind[i] == 0:
          q.append(snake_case__    )
    if len(snake_case__    ) == 0:
      return
    _UpperCAmelCase		:       Dict       =    q.popleft()
    print(snake_case__    )
    for w in g[v]:
      ind[w] -= 1
      if ind[w] == 0:
        q.append(snake_case__    )
    topo(snake_case__	,      snake_case__	,      snake_case__    )
  
  
  
  
  def       a__						(		):
    _UpperCAmelCase		:       Tuple       =    input().strip()
    _UpperCAmelCase		:       int       =    []
    for _ in range(snake_case__    ):
      a.append(map(snake_case__	,      input().strip().split()    )    )
    return a, n
  
  
  
  
  def       a__						(		snake_case__				:       int    ):
    ((_UpperCAmelCase),(_UpperCAmelCase))		:       str       =    a_and_n
    _UpperCAmelCase		:       str       =    list(snake_case__    )
    _UpperCAmelCase		:       Union[str, Any]       =    [[0] * n for i in range(snake_case__    )]
    for k in range(snake_case__    ):
      for i in range(snake_case__    ):
        for j in range(snake_case__    ):
          if dist[i][j] > dist[i][k] + dist[k][j]:
            _UpperCAmelCase		:       Union[str, Any]       =    dist[i][k] + dist[k][j]
            _UpperCAmelCase		:       Union[str, Any]       =    k
    print(snake_case__    )
  
  
  
  
  def       a__						(		snake_case__				:       Tuple	,      snake_case__				:       int    ):
    _UpperCAmelCase,_UpperCAmelCase,_UpperCAmelCase		:       Any       =    {s: 0}, set(), {s: 0}
    while True:
      if len(snake_case__    ) == len(snake_case__    ) - 1:
        break
      _UpperCAmelCase		:       int       =    10_0000
      for i in dist:
        if i not in known and dist[i] < mini:
          _UpperCAmelCase		:       List[Any]       =    dist[i]
          _UpperCAmelCase		:       Union[str, Any]       =    i
      known.add(snake_case__    )
      for v in g[u]:
        if v[0] not in known and v[1] < dist.get(v[0]	,      10_0000    ):
          _UpperCAmelCase		:       Any       =    v[1]
          _UpperCAmelCase		:       int       =    u
    return dist
  
  
  
  
  def       a__						(		):
    _UpperCAmelCase,_UpperCAmelCase		:       List[str]       =    map(snake_case__	,      input().split(""" """    )    )
    _UpperCAmelCase		:       Dict       =    []
    for _ in range(snake_case__    ):
      edges.append(map(snake_case__	,      input().split(""" """    )    )    )
    return edges, n
  
  
  
  
  def       a__						(		snake_case__				:       List[Any]    ):
    # Sort edges on the basis of distance
    ((_UpperCAmelCase),(_UpperCAmelCase))		:       Optional[Any]       =    e_and_n
    e.sort(reverse=snake_case__	,      key=lambda snake_case__    : x[2]    )
    _UpperCAmelCase		:       List[str]       =    [{i} for i in range(1	,      n + 1    )]
    while True:
      if len(snake_case__    ) == 1:
        break
      print(snake_case__    )
      _UpperCAmelCase		:       int       =    e.pop()
      for i in range(len(snake_case__    )    ):
        if x[0] in s[i]:
          break
      for j in range(len(snake_case__    )    ):
        if x[1] in s[j]:
          if i == j:
            break
          s[j].update(s[i]    )
          s.pop(snake_case__    )
          break
  
  
  
  
  
  def       a__						(		snake_case__				:       int    ):
    _UpperCAmelCase		:       Union[str, Any]       =    []
    for node in graph:
      if not graph[node]:
        isolated.append(snake_case__    )
    return isolated
  
  
  
  
  
  
style_context: 
  
  
  import os
  
  import requests
  from bsa import BeautifulSoup
  from fake_useragent import UserAgent
  
  SCREAMING_SNAKE_CASE__				:    int         =    {'UserAgent': UserAgent().random}
  SCREAMING_SNAKE_CASE__				:    Tuple         =    'https://www.mywaifulist.moe/random'
  
  
  
  
  def       a__						(		snake_case__				:       str	,      snake_case__				:       str    ):
    _UpperCAmelCase		:       Any       =    requests.get(snake_case__	,      headers=snake_case__    )
    with open(snake_case__	,      """wb"""    ) as file:
      file.write(image.content    )
  
  
  
  
  def       a__						(		):
    _UpperCAmelCase		:       List[Any]       =    BeautifulSoup(requests.get(snake_case__	,      headers=snake_case__    ).text	,      """html.parser"""    )
    _UpperCAmelCase		:       Optional[int]       =    soup.find("""meta"""	,      attrs={"""property""": """og:title"""}    ).attrs["""content"""]
    _UpperCAmelCase		:       int       =    soup.find("""meta"""	,      attrs={"""property""": """og:image"""}    ).attrs["""content"""]
    _UpperCAmelCase		:       Any       =    soup.find("""p"""	,      id="""description"""    ).get_text()
    _UpperCAmelCase,_UpperCAmelCase		:       Dict       =    os.path.splitext(os.path.basename(snake_case__    )    )
    _UpperCAmelCase		:       Tuple       =    title.strip().replace(""" """	,      """_"""    )
    _UpperCAmelCase		:       Optional[Any]       =    f'''{image_title}{image_extension}'''
    save_image(snake_case__	,      snake_case__    )
    return (title, description, image_title)
  
  
  if __name__ == "__main__":
   SCREAMING_SNAKE_CASE__     ,				SCREAMING_SNAKE_CASE__     ,				SCREAMING_SNAKE_CASE__				:    Optional[int]         =    random_anime_character()
   print(F'{title}\n\n{desc}\n\nImage saved : {image_title}')
  
  
  
  
  
  