

import heapq as hq
import math
from collections.abc import Iterator


class  A						:







    """simple docstring"""





    def __init__(      self :       Optional[Any],lowercase_ :       Union[str, Any]		)->    Optional[int]:





        '''simple docstring'''







        A__          =   str(id_		)
        A__          =   None
        A__          =   None
        A__          =   []
        A__          =   {}  # {vertex:distance}


    def __lt__(      self :       Dict,lowercase_ :       str		)->    List[Any]:





        '''simple docstring'''







        return self.key < other.key


    def __repr__(      self :       Dict		)->    int:





        '''simple docstring'''







        return self.id


    def 						snake_case__     (      self :       str,lowercase_ :       List[Any]		)->    List[str]:





        '''simple docstring'''







        self.neighbors.append(lowercase_		)


    def 						snake_case__     (      self :       List[Any],lowercase_ :       Tuple,lowercase_ :       List[Any]		)->    Any:





        '''simple docstring'''







        A__          =   weight




def 						_snake_case(    SCREAMING_SNAKE_CASE__			:	List[str]    ,			SCREAMING_SNAKE_CASE__			:	Union[str, Any]    ,			SCREAMING_SNAKE_CASE__			:	int    ,			SCREAMING_SNAKE_CASE__			:	str      )							->      Union[str, Any]:





    '''simple docstring'''






    graph[a - 1].add_neighbor(graph[b - 1]      )
    graph[b - 1].add_neighbor(graph[a - 1]      )
    # add the edges:
    graph[a - 1].add_edge(graph[b - 1]    ,			UpperCamelCase__      )
    graph[b - 1].add_edge(graph[a - 1]    ,			UpperCamelCase__      )
def 						_snake_case(    SCREAMING_SNAKE_CASE__			:	list    ,			SCREAMING_SNAKE_CASE__			:	Vertex      )							->      Any:





    '''simple docstring'''






    A__          =   []
    for u in graph:
        A__          =   math.inf
        A__          =   None
    A__          =   0
    A__          =   graph[:]
    while q:
        A__          =   min(UpperCamelCase__      )
        q.remove(UpperCamelCase__      )
        for v in u.neighbors:
            if (v in q) and (u.edges[v.id] < v.key):
                A__          =   u
                A__          =   u.edges[v.id]
    for i in range(1    ,			len(UpperCamelCase__      )      ):
        a.append((int(graph[i].id      ) + 1, int(graph[i].pi.id      ) + 1)      )
    return a
def 						_snake_case(    SCREAMING_SNAKE_CASE__			:	list    ,			SCREAMING_SNAKE_CASE__			:	Vertex      )							->      Optional[int]:





    '''simple docstring'''






    for u in graph:
        A__          =   math.inf
        A__          =   None
    A__          =   0

    A__          =   list(UpperCamelCase__      )
    hq.heapify(UpperCamelCase__      )

    while h:
        A__          =   hq.heappop(UpperCamelCase__      )
        for v in u.neighbors:
            if (v in h) and (u.edges[v.id] < v.key):
                A__          =   u
                A__          =   u.edges[v.id]
                hq.heapify(UpperCamelCase__      )

    for i in range(1    ,			len(UpperCamelCase__      )      ):
        yield (int(graph[i].id      ) + 1, int(graph[i].pi.id      ) + 1)
def 						_snake_case(    )							->      int:





    '''simple docstring'''






    pass


if __name__ == "__main__":
     import doctest

     doctest.testmod()






"""simple docstring"""
def  lowerCamelCase_						(UpperCamelCase__		:		int							):
    if not isinstance(UpperCamelCase__     ,       UpperCamelCase__							) or number < 0:
        raise ValueError('''Input must be a non-negative integer'''							)

    _UpperCAmelCase							:  str											=    0
    while number:
        # This way we arrive at next set bit (next 1) instead of looping
        # through each bit and checking for 1s hence the
        # loop won't run 32 times it will only run the number of `1` times
        number &= number - 1
        count += 1
    return count


if __name__ == "__main__":
  import doctest

  doctest.testmod()


