





__lowerCamelCase			:	List[Any]					    =	[
    (1000, """M"""),
    (900, """CM"""),
    (500, """D"""),
    (400, """CD"""),
    (100, """C"""),
    (90, """XC"""),
    (50, """L"""),
    (40, """XL"""),
    (10, """X"""),
    (9, """IX"""),
    (5, """V"""),
    (4, """IV"""),
    (1, """I"""),
]



def 						A_							(	_lowerCAmelCase	)		->					int:
 UpperCamelCase      :   Any			      =  {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000}
 UpperCamelCase      :   str			      =  0
 UpperCamelCase      :   str			      =  0
 while place < len(_lowerCAmelCase	):
  if (place + 1 < len(_lowerCAmelCase	)) and (vals[roman[place]] < vals[roman[place + 1]]):
   total += vals[roman[place + 1]] - vals[roman[place]]
   place += 2
  else:
   total += vals[roman[place]]
   place += 1
 return total



def 						A_							(	_lowerCAmelCase	)		->					str:
 UpperCamelCase      :   int			      =  []
 for arabic, roman in ROMAN:
  ((UpperCamelCase)      ,       (UpperCamelCase))      :   Tuple			      =  divmod(_lowerCAmelCase				,  _lowerCAmelCase	)
  result.append(roman * factor	)
  if number == 0:
   break
 return "".join(_lowerCAmelCase	)


if __name__ == "__main__":
    import doctest

    doctest.testmod()







# Author: OMKAR PATHAK, Nwachukwu Chidiebere

# Use a Python dictionary to construct the graph.
from __future__ import annotations

from pprint import pformat
from typing import Generic, TypeVar

__lowerCamelCase			:	str					    =	TypeVar("""T""")



class    A__  (			Generic[T]     ):





      def __init__(					self			,				A_ = True  ):
       '''simple docstring'''




       UpperCamelCase      :   dict[T, list[T]]			      =  {}  # dictionary of lists
       UpperCamelCase      :   Union[str, Any]			      =  directed





      def 			__UpperCamelCase(					self			,				A_			,				A_  ):
       '''simple docstring'''




       if not self.directed:  # For undirected graphs
        # if both source vertex and destination vertex are both present in the
        # adjacency list, add destination vertex to source vertex list of adjacent
        # vertices and add source vertex to destination vertex list of adjacent
        # vertices.
        if source_vertex in self.adj_list and destination_vertex in self.adj_list:
         self.adj_list[source_vertex].append(A_  )
         self.adj_list[destination_vertex].append(A_  )
        # if only source vertex is present in adjacency list, add destination vertex
        # to source vertex list of adjacent vertices, then create a new vertex with
        # destination vertex as key and assign a list containing the source vertex
        # as it's first adjacent vertex.
        elif source_vertex in self.adj_list:
         self.adj_list[source_vertex].append(A_  )
         UpperCamelCase      :   Any			      =  [source_vertex]
        # if only destination vertex is present in adjacency list, add source vertex
        # to destination vertex list of adjacent vertices, then create a new vertex
        # with source vertex as key and assign a list containing the source vertex
        # as it's first adjacent vertex.
        elif destination_vertex in self.adj_list:
         self.adj_list[destination_vertex].append(A_  )
         UpperCamelCase      :   Any			      =  [destination_vertex]
        # if both source vertex and destination vertex are not present in adjacency
        # list, create a new vertex with source vertex as key and assign a list
        # containing the destination vertex as it's first adjacent vertex also
        # create a new vertex with destination vertex as key and assign a list
        # containing the source vertex as it's first adjacent vertex.
        else:
         UpperCamelCase      :   Union[str, Any]			      =  [destination_vertex]
         UpperCamelCase      :   List[str]			      =  [source_vertex]
       else:  # For directed graphs
        # if both source vertex and destination vertex are present in adjacency
        # list, add destination vertex to source vertex list of adjacent vertices.
        if source_vertex in self.adj_list and destination_vertex in self.adj_list:
         self.adj_list[source_vertex].append(A_  )
        # if only source vertex is present in adjacency list, add destination
        # vertex to source vertex list of adjacent vertices and create a new vertex
        # with destination vertex as key, which has no adjacent vertex
        elif source_vertex in self.adj_list:
         self.adj_list[source_vertex].append(A_  )
         UpperCamelCase      :   List[str]			      =  []
        # if only destination vertex is present in adjacency list, create a new
        # vertex with source vertex as key and assign a list containing destination
        # vertex as first adjacent vertex
        elif destination_vertex in self.adj_list:
         UpperCamelCase      :   Union[str, Any]			      =  [destination_vertex]
        # if both source vertex and destination vertex are not present in adjacency
        # list, create a new vertex with source vertex as key and a list containing
        # destination vertex as it's first adjacent vertex. Then create a new vertex
        # with destination vertex as key, which has no adjacent vertex
        else:
         UpperCamelCase      :   Union[str, Any]			      =  [destination_vertex]
         UpperCamelCase      :   Dict			      =  []

       return self





      def __repr__(					self  ):
       '''simple docstring'''




       return pformat(self.adj_list  )
