






"""simple docstring"""






def  __lowerCamelCase					(					lowerCAmelCase__				):
				A__							 =       [0] * len(lowerCAmelCase__				)
				A__							 =       []
				A__							 =       []
				A__							 =       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:
								A__							 =       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
SCREAMING_SNAKE_CASE						:						List[str]					   =       {0: [1, 2], 1: [3], 2: [3], 3: [4, 5], 4: [], 5: []}







topological_sort(graph)










"""simple docstring"""






from PIL import Image



def  __lowerCamelCase					(					lowerCAmelCase__				):
				A__ ,			A__							 =       image.size
				A__							 =       0
				A__							 =       image.load()
				for i in range(lowerCAmelCase__				):
								for j in range(lowerCAmelCase__				):
												A__							 =       pixels[j, i]
												mean += pixel
				mean //= width * height

				for j in range(lowerCAmelCase__				):
								for i in range(lowerCAmelCase__				):
												A__							 =       255 if pixels[i, j] > mean else 0
				return image


if __name__ == "__main__":
					SCREAMING_SNAKE_CASE						:						Dict					   =       mean_threshold(Image.open('''path_to_image''').convert('''L'''))
					image.save('''output_image_path''')


