




"""simple docstring"""







def 						snake_case__       (					_lowerCamelCase				)			->int:






		"""simple docstring"""


		__lowercase				:		str												=				[0] * len(_lowerCamelCase				)
		__lowercase				:		Union[str, Any]												=				[]
		__lowercase				:		List[Any]												=				[]
		__lowercase				:		Optional[int]												=				0

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

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

		while queue:
				__lowercase				:		Union[str, Any]												=				queue.pop(0				)
				cnt += 1
				topo.append(_lowerCamelCase				)
				for x in graph[vertex]:
						indegree[x] -= 1
						if indegree[x] == 0:
								queue.append(_lowerCamelCase				)

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


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





topological_sort(graph)






"""simple docstring"""







class       lowerCAmelCase__       :


				"""simple docstring"""





				def __init__(     self					:	int    ,   lowercase__					:	List[Any]						):
						__lowercase				:		Tuple												=				val
						__lowercase				:		Optional[Any]												=				None
						__lowercase				:		Tuple												=				None



				def       snake_case    (     self					:	Optional[Any]    ,   lowercase__					:	List[str]						):
						if self.val:
								if val < self.val:
										if self.left is None:
												__lowercase				:		Tuple												=				Node(lowercase__						)
										else:
												self.left.insert(lowercase__						)
								elif val > self.val:
										if self.right is None:
												__lowercase				:		Any												=				Node(lowercase__						)
										else:
												self.right.insert(lowercase__						)
						else:
								__lowercase				:		Optional[Any]												=				val





def 						snake_case__       (					_lowerCamelCase,  _lowerCamelCase				)			->Any:






		"""simple docstring"""


		if root:
				inorder(root.left,  _lowerCamelCase				)
				res.append(root.val				)
				inorder(root.right,  _lowerCamelCase				)

def 						snake_case__       (					_lowerCamelCase				)			->Optional[Any]:






		"""simple docstring"""


		if len(_lowerCamelCase				) == 0:
				return arr
		__lowercase				:		int												=				Node(arr[0]				)
		for i in range(1,  len(_lowerCamelCase				)				):
				root.insert(arr[i]				)
		# Traverse BST in order.
		__lowercase				:		Tuple												=				[]
		inorder(_lowerCamelCase,  _lowerCamelCase				)
		return res


if __name__ == "__main__":
						print(tree_sort([1_0, 1, 3, 2, 9, 1_4, 1_3]))
