'''simple docstring'''




_a   :	List[str] 							=   {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}

_a   :	int 							=   {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__							,    lowerCamelCase__						)					->       list[int]:





       """simple docstring"""


       __UpperCAmelCase  :				int       				=		True
       __UpperCAmelCase  :				Dict       				=		[]

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

       order.append(lowerCamelCase__						)

       return order

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__							,    lowerCamelCase__						)					->       list[int]:





       """simple docstring"""


       __UpperCAmelCase  :				List[str]       				=		True
       __UpperCAmelCase  :				Tuple       				=		[vert]

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

       return component


def _lowercase	(      lowerCamelCase__						)					->       list[list[int]]:





       """simple docstring"""


       __UpperCAmelCase  :				Dict       				=		len(lowerCamelCase__						) * [False]
       __UpperCAmelCase  :				dict[int, list[int]]       				=		{vert: [] for vert in range(len(lowerCamelCase__						)						)}

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

       __UpperCAmelCase  :				List[str]       				=		[]
       for i, was_visited in enumerate(lowerCamelCase__						):
              if not was_visited:
                     order += topology_sort(lowerCamelCase__							,    lowerCamelCase__							,    lowerCamelCase__						)

       __UpperCAmelCase  :				Dict       				=		[]
       __UpperCAmelCase  :				int       				=		len(lowerCamelCase__						) * [False]

       for i in range(len(lowerCamelCase__						)						):
              __UpperCAmelCase  :				Optional[int]       				=		order[len(lowerCamelCase__						) - i - 1]
              if not visited[vert]:
                     __UpperCAmelCase  :				Dict       				=		find_components(lowerCamelCase__							,    lowerCamelCase__							,    lowerCamelCase__						)
                     components_list.append(lowerCamelCase__						)

       return components_list







'''simple docstring'''




def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__							,    lowerCamelCase__						)					->       bool:





       """simple docstring"""


       return not any(
           neighbour == 1 and colored_vertices[i] == color
           for i, neighbour in enumerate(lowerCamelCase__						)						)

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__							,    lowerCamelCase__							,    lowerCamelCase__						)					->       bool:





       """simple docstring"""


       if index == len(lowerCamelCase__						):
              return True

       # Recursive Step
       for i in range(lowerCamelCase__						):
              if valid_coloring(graph[index]							,    lowerCamelCase__							,    lowerCamelCase__						):
                     # Color current vertex
                     __UpperCAmelCase  :				List[str]       				=		i
                     # Validate coloring
                     if util_color(lowerCamelCase__							,    lowerCamelCase__							,    lowerCamelCase__							,    index + 1						):
                            return True
                     # Backtrack
                     __UpperCAmelCase  :				Any       				=		-1
       return False


def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       list[int]:





       """simple docstring"""


       __UpperCAmelCase  :				Optional[Any]       				=		[-1] * len(lowerCamelCase__						)

       if util_color(lowerCamelCase__							,    lowerCamelCase__							,    lowerCamelCase__							,    0						):
              return colored_vertices

       return []






