class 				lowercase       :




				def __init__(      self   ,     snake_case   ,     snake_case   ,     snake_case ):
											snake_case_           =					None
											snake_case_           =					None
											snake_case_           =					graph

											self._normalize_graph(A_   ,     A_ )
											snake_case_           =					len(A_ )
											snake_case_           =					None




				def 					a							(      self   ,     snake_case   ,     snake_case ):
											if sources is int:
																		snake_case_           =					[sources]
											if sinks is int:
																		snake_case_           =					[sinks]

											if len(A_ ) == 0 or len(A_ ) == 0:
																		return

											snake_case_           =					sources[0]
											snake_case_           =					sinks[0]

											# make fake vertex if there are more
											# than one source or sink
											if len(A_ ) > 1 or len(A_ ) > 1:
																		snake_case_           =					0
																		for i in sources:
																									max_input_flow += sum(self.graph[i] )

																		snake_case_           =					len(self.graph ) + 1
																		for room in self.graph:
																									room.insert(0   ,     0 )
																		self.graph.insert(0   ,     [0] * size )
																		for i in sources:
																									snake_case_           =					max_input_flow
																		snake_case_           =					0

																		snake_case_           =					len(self.graph ) + 1
																		for room in self.graph:
																									room.append(0 )
																		self.graph.append([0] * size )
																		for i in sinks:
																									snake_case_           =					max_input_flow
																		snake_case_           =					size - 1




				def 					a							(      self ):
											if self.maximum_flow_algorithm is None:
																		raise Exception('You need to set maximum flow algorithm before.' )
											if self.source_index is None or self.sink_index is None:
																		return 0

											self.maximum_flow_algorithm.execute()
											return self.maximum_flow_algorithm.getMaximumFlow()




				def 					a							(      self   ,     snake_case ):
											snake_case_           =					algorithm(self )







class 				lowercase       :




				def __init__(      self   ,     snake_case ):
											snake_case_           =					flow_network
											snake_case_           =					flow_network.verticesCount
											snake_case_           =					flow_network.sourceIndex
											snake_case_           =					flow_network.sinkIndex
											# it's just a reference, so you shouldn't change
											# it in your algorithms, use deep copy before doing that
											snake_case_           =					flow_network.graph
											snake_case_           =					False




				def 					a							(      self ):
											if not self.executed:
																		self._algorithm()
																		snake_case_           =					True




				def 					a							(      self ):
											pass







class 				lowercase       ( _SCREAMING_SNAKE_CASE    ):




				def __init__(      self   ,     snake_case ):
											super().__init__(A_ )
											# use this to save your result
											snake_case_           =					-1




				def 					a							(      self ):
											if not self.executed:
																		raise Exception('You should execute algorithm before using its result!' )

											return self.maximum_flow







class 				lowercase       ( _SCREAMING_SNAKE_CASE    ):




				def __init__(      self   ,     snake_case ):
											super().__init__(A_ )

											snake_case_           =					[[0] * self.verticies_count for i in range(self.verticies_count )]

											snake_case_           =					[0] * self.verticies_count
											snake_case_           =					[0] * self.verticies_count




				def 					a							(      self ):
											snake_case_           =					self.verticies_count

											# push some substance to graph
											for nextvertex_index, bandwidth in enumerate(self.graph[self.source_index] ):
																		self.preflow[self.source_index][nextvertex_index] += bandwidth
																		self.preflow[nextvertex_index][self.source_index] -= bandwidth
																		self.excesses[nextvertex_index] += bandwidth

											# Relabel-to-front selection rule
											snake_case_           =					[
											    i
											    for i in range(self.verticies_count )
											    if i != self.source_index and i != self.sink_index
											]

											# move through list
											snake_case_           =					0
											while i < len(A_ ):
																		snake_case_           =					vertices_list[i]
																		snake_case_           =					self.heights[vertex_index]
																		self.process_vertex(A_ )
																		if self.heights[vertex_index] > previous_height:
																									# if it was relabeled, swap elements
																									# and start from 0 index
																									vertices_list.insert(0   ,     vertices_list.pop(A_ ) )
																									snake_case_           =					0
																		else:
																									i += 1

											snake_case_           =					sum(self.preflow[self.source_index] )




				def 					a							(      self   ,     snake_case ):
											while self.excesses[vertex_index] > 0:
																		for neighbour_index in range(self.verticies_count ):
																									# if it's neighbour and current vertex is higher
																									if (
																									    self.graph[vertex_index][neighbour_index]
																									    - self.preflow[vertex_index][neighbour_index]
																									    > 0
																									    and self.heights[vertex_index] > self.heights[neighbour_index]
																									):
																																self.push(A_   ,     A_ )

																		self.relabel(A_ )




				def 					a							(      self   ,     snake_case   ,     snake_case ):
											snake_case_           =					min(
											    self.excesses[from_index]   ,     self.graph[from_index][to_index] - self.preflow[from_index][to_index]   ,     )
											self.preflow[from_index][to_index] += preflow_delta
											self.preflow[to_index][from_index] -= preflow_delta
											self.excesses[from_index] -= preflow_delta
											self.excesses[to_index] += preflow_delta




				def 					a							(      self   ,     snake_case ):
											snake_case_           =					None
											for to_index in range(self.verticies_count ):
																		if (
																		    self.graph[vertex_index][to_index]
																		    - self.preflow[vertex_index][to_index]
																		    > 0
																		) and (min_height is None or self.heights[to_index] < min_height):
																									snake_case_           =					self.heights[to_index]

											if min_height is not None:
																		snake_case_           =					min_height + 1


if __name__ == "__main__":
					_UpperCAmelCase	:     str		       = [0]
					_UpperCAmelCase	:     List[str]		       = [3]
					# graph = [
					#     [0, 0, 4, 6, 0, 0],
					#     [0, 0, 5, 2, 0, 0],
					#     [0, 0, 0, 0, 4, 4],
					#     [0, 0, 0, 0, 6, 6],
					#     [0, 0, 0, 0, 0, 0],
					#     [0, 0, 0, 0, 0, 0],
					# ]
					_UpperCAmelCase	:     Optional[Any]		       = [[0, 7, 0, 0], [0, 0, 6, 0], [0, 0, 0, 8], [9, 0, 0, 0]]

					# prepare our network
					_UpperCAmelCase	:     Any		       = FlowNetwork(graph, entrances, exits)
					# set algorithm
					flow_network.set_maximum_flow_algorithm(PushRelabelExecutor)
					# and calculate
					_UpperCAmelCase	:     str		       = flow_network.find_maximum_flow()

					print(F'''maximum flow is {maximum_flow}''')







def       __lowerCamelCase			(				UpperCamelCase__ = 50000000   ):







							'''simple docstring'''






							snake_case_           =					set()
							snake_case_           =					int((limit - 24) ** (1 / 2)   )

							snake_case_           =					set(range(3     ,							prime_square_limit + 1     ,							2   )   )
							primes.add(2   )
							for p in range(3     ,							prime_square_limit + 1     ,							2   ):
														if p not in primes:
																					continue
														primes.difference_update(set(range(p * p     ,							prime_square_limit + 1     ,							UpperCamelCase__   )   )   )

							for primea in primes:
														snake_case_           =					primea * primea
														for primea in primes:
																					snake_case_           =					primea * primea * primea
																					if square + cube >= limit - 16:
																												break
																					for primea in primes:
																												snake_case_           =					primea * primea * primea * primea
																												snake_case_           =					square + cube + tetr
																												if total >= limit:
																																			break
																												ret.add(UpperCamelCase__   )

							return len(UpperCamelCase__   )


if __name__ == "__main__":
					print(F'''{solution() = }''')




