


def 							_UpperCAmelCase				(UpperCamelCase__     :  str				,							UpperCamelCase__     :  str						):

       if not (isinstance(UpperCamelCase__				,							UpperCamelCase__						) and isinstance(UpperCamelCase__				,							UpperCamelCase__						)):
              raise ValueError("longest_common_substring() takes two strings for inputs"						)

       _A      :       Union[str, Any]				    = len(UpperCamelCase__						)
       _A      :       List[Any]				    = len(UpperCamelCase__						)

       _A      :       Tuple				    = [[0] * (texta_length + 1) for _ in range(texta_length + 1						)]
       _A      :       int				    = 0
       _A      :       Union[str, Any]				    = 0

       for i in range(1				,							texta_length + 1						):
              for j in range(1				,							texta_length + 1						):
                     if texta[i - 1] == texta[j - 1]:
                            _A      :       Optional[Any]				    = 1 + dp[i - 1][j - 1]
                            if dp[i][j] > ans_length:
                                   _A      :       Any				    = i
                                   _A      :       Dict				    = dp[i][j]

       return texta[ans_index - ans_length : ans_index]


if __name__ == "__main__":
    import doctest

    doctest.testmod()







a__:      Dict									=		{0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}

a__:      str									=		{0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}


def 	UpperCamelCase__(       UpperCamelCase__			:       dict[int, list[int]] ,     UpperCamelCase__			:       int ,     UpperCamelCase__			:       list[bool]  )->list[int]:
       A__											=						True
       A__											=						[]

       for neighbour in graph[vert]:
              if not visited[neighbour]:
                     order += topology_sort(UpperCamelCase__ ,     UpperCamelCase__ ,     UpperCamelCase__  )

       order.append(UpperCamelCase__  )

       return order


def 	UpperCamelCase__(       UpperCamelCase__			:       dict[int, list[int]] ,     UpperCamelCase__			:       int ,     UpperCamelCase__			:       list[bool]  )->list[int]:
       A__											=						True
       A__											=						[vert]

       for neighbour in reversed_graph[vert]:
              if not visited[neighbour]:
                     component += find_components(UpperCamelCase__ ,     UpperCamelCase__ ,     UpperCamelCase__  )

       return component


def 	UpperCamelCase__(       UpperCamelCase__			:       dict[int, list[int]]  )->list[list[int]]:
       A__											=						len(UpperCamelCase__  ) * [False]
       A__											=						{vert: [] for vert in range(len(UpperCamelCase__  )  )}

       for vert, neighbours in graph.items():
              for neighbour in neighbours:
                     reversed_graph[neighbour].append(UpperCamelCase__  )

       A__											=						[]
       for i, was_visited in enumerate(UpperCamelCase__  ):
              if not was_visited:
                     order += topology_sort(UpperCamelCase__ ,     UpperCamelCase__ ,     UpperCamelCase__  )

       A__											=						[]
       A__											=						len(UpperCamelCase__  ) * [False]

       for i in range(len(UpperCamelCase__  )  ):
              A__											=						order[len(UpperCamelCase__  ) - i - 1]
              if not visited[vert]:
                     A__											=						find_components(UpperCamelCase__ ,     UpperCamelCase__ ,     UpperCamelCase__  )
                     components_list.append(UpperCamelCase__  )

       return components_list





