


def 							UpperCamelCase_(					_A :list[int]	)->		list[list[int]]:
			UpperCamelCase__       =							[]
			if len(_A	) == 1:
						return [nums.copy()]
			for _ in range(len(_A	)	):
						UpperCamelCase__       =							nums.pop(0	)
						UpperCamelCase__       =							permute(_A	)
						for perm in permutations:
									perm.append(_A	)
						result.extend(_A	)
						nums.append(_A	)
			return result
def 							UpperCamelCase_(					_A :Dict	)->		Any:

			def backtrack(_A :Any	):
						if start == len(_A	) - 1:
									output.append(nums[:]	)
						else:
									for i in range(_A					,  len(_A	)	):
												UpperCamelCase__,   UpperCamelCase__       =							nums[i], nums[start]
												backtrack(start + 1	)
												UpperCamelCase__,   UpperCamelCase__       =							nums[i], nums[start]  # backtrack

			UpperCamelCase__       =							[]
			backtrack(0	)
			return output


if __name__ == "__main__":
						import doctest

						# use res to print the data in permute2 function
						__UpperCamelCase     		=							permutea([1, 2, 3])
						print(res)
						doctest.testmod()






def 							UpperCamelCase_(					_A :Union[str, Any]	)->		List[str]:
			UpperCamelCase__       =							[0] * len(_A	)
			UpperCamelCase__       =							[]
			UpperCamelCase__       =							[]
			UpperCamelCase__       =							0

			for values in graph.values():
						for i in values:
									indegree[i] += 1

			for i in range(len(_A	)	):
						if indegree[i] == 0:
									queue.append(_A	)

			while queue:
						UpperCamelCase__       =							queue.pop(0	)
						cnt += 1
						topo.append(_A	)
						for x in graph[vertex]:
									indegree[x] -= 1
									if indegree[x] == 0:
												queue.append(_A	)

			if cnt != len(_A	):
						print("Cycle exists"	)
			else:
						print(_A	)


# Adjacency List of Graph
__UpperCamelCase     		=							{0: [1, 2], 1: [3], 2: [3], 3: [4, 5], 4: [], 5: []}







topological_sort(graph)


