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

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






def      lowerCamelCase__       (       __lowerCAmelCase						:						dict[int, list[int]]					,							__lowerCAmelCase						:						int					,							__lowerCAmelCase						:						list[bool]       ):




			"""simple docstring"""


			lowerCAmelCase_      			=			True
			lowerCAmelCase_      			=			[]

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

			order.append(__lowerCAmelCase       )

			return order






def      lowerCamelCase__       (       __lowerCAmelCase						:						dict[int, list[int]]					,							__lowerCAmelCase						:						int					,							__lowerCAmelCase						:						list[bool]       ):




			"""simple docstring"""


			lowerCAmelCase_      			=			True
			lowerCAmelCase_      			=			[vert]

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

			return component






def      lowerCamelCase__       (       __lowerCAmelCase						:						dict[int, list[int]]       ):




			"""simple docstring"""


			lowerCAmelCase_      			=			len(__lowerCAmelCase       ) * [False]
			lowerCAmelCase_      			=			{vert: [] for vert in range(len(__lowerCAmelCase       )       )}

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

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

			lowerCAmelCase_      			=			[]
			lowerCAmelCase_      			=			len(__lowerCAmelCase       ) * [False]

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

			return components_list





def      lowerCamelCase__       (       __lowerCAmelCase						:						list[list[int]]					,							__lowerCAmelCase						:						int					,							__lowerCAmelCase						:						int					,							__lowerCAmelCase						:						set       ):




			"""simple docstring"""


			lowerCAmelCase_			,						lowerCAmelCase_      			=			len(__lowerCAmelCase       ), len(grid[0]       )
			if (
			    min(__lowerCAmelCase					,							__lowerCAmelCase       ) < 0
			    or row == row_length
			    or col == col_length
			    or (row, col) in visit
			    or grid[row][col] == 1
			):
						return 0
			if row == row_length - 1 and col == col_length - 1:
						return 1

			visit.add((row, col)       )

			lowerCAmelCase_      			=			0
			count += depth_first_search(__lowerCAmelCase					,							row + 1					,							__lowerCAmelCase					,							__lowerCAmelCase       )
			count += depth_first_search(__lowerCAmelCase					,							row - 1					,							__lowerCAmelCase					,							__lowerCAmelCase       )
			count += depth_first_search(__lowerCAmelCase					,							__lowerCAmelCase					,							col + 1					,							__lowerCAmelCase       )
			count += depth_first_search(__lowerCAmelCase					,							__lowerCAmelCase					,							col - 1					,							__lowerCAmelCase       )

			visit.remove((row, col)       )
			return count


if __name__ == "__main__":
			import doctest

			doctest.testmod()



