
lowercase__						:int					    =       float("inf")







class 							lowercase						:




							def __init__(							self  ,A__):
												lowercase		      =		[0] * n
												lowercase		      =		[0] * n
												lowercase		      =		[0] * n
												lowercase		      =		[[] for _ in range(SCREAMING_SNAKE_CASE_)]




							def 					A__ (							self  ,A__  ,A__  ,A__  ,A__=0):
												self.adj[a].append([b, len(self.adj[b]), c, 0])
												self.adj[b].append([a, len(self.adj[a]) - 1, rcap, 0])




							def 					A__ (							self  ,A__  ,A__  ,A__):
												if vertex == sink or not flow:
																	return flow

												for i in range(self.ptr[vertex]  ,len(self.adj[vertex])):
																	lowercase		      =		self.adj[vertex][i]
																	if self.lvl[e[0]] == self.lvl[vertex] + 1:
																						lowercase		      =		self.depth_first_search(e[0]  ,SCREAMING_SNAKE_CASE_  ,min(SCREAMING_SNAKE_CASE_  ,e[2] - e[3]))
																						if p:
																											self.adj[vertex][i][3] += p
																											self.adj[e[0]][e[1]][3] -= p
																											return p
																	lowercase		      =		self.ptr[vertex] + 1
												return 0





							def 					A__ (							self  ,A__  ,A__):
												lowercase		      =		0, source
												for l in range(3_1):  # noqa: E741  l = 30 maybe faster for random data
																	while True:
																						lowercase		      =		[0] * len(self.q), [0] * len(self.q)
																						lowercase		      =		0, 1, 1
																						while qi < qe and not self.lvl[sink]:
																											lowercase		      =		self.q[qi]
																											qi += 1
																											for e in self.adj[v]:
																																if not self.lvl[e[0]] and (e[2] - e[3]) >> (3_0 - l):
																																					lowercase		      =		e[0]
																																					qe += 1
																																					lowercase		      =		self.lvl[v] + 1

																						lowercase		      =		self.depth_first_search(SCREAMING_SNAKE_CASE_  ,SCREAMING_SNAKE_CASE_  ,SCREAMING_SNAKE_CASE_)
																						while p:
																											flow += p
																											lowercase		      =		self.depth_first_search(SCREAMING_SNAKE_CASE_  ,SCREAMING_SNAKE_CASE_  ,SCREAMING_SNAKE_CASE_)

																						if not self.lvl[sink]:
																											break

												return flow


lowercase__						:List[str]					    =       Dinic(10)
lowercase__						:Optional[Any]					    =       0
lowercase__						:Optional[Any]					    =       9
for vertex in range(1, 5):
							graph.add_edge(source, vertex, 1)
for vertex in range(5, 9):
							graph.add_edge(vertex, sink, 1)
for vertex in range(1, 5):
							graph.add_edge(vertex, vertex + 4, 1)

# Now we can know that is the maximum flow(source -> sink)
print(graph.max_flow(source, sink))








_A		:					Union[str, Any]          =							1_000



def      __lowerCAmelCase    (				snake_case						:     float			)							->				float:
   return x * x



def      __lowerCAmelCase    (				snake_case						:     Optional[int]    ,   snake_case						:     float    ,   snake_case						:     float    ,   snake_case						:     int = 4			)							->				float:
   assert callable(
       snake_case			), f'the function(object) passed should be callable your input : {function}'
   assert isinstance(snake_case    ,   (float, int)			), f'a should be float or integer your input : {a}'
   assert isinstance(function(snake_case			)    ,   (float, int)			), (
       "the function should return integer or float return type of your function, "
       f'{type(snake_case			)}'
   )
   assert isinstance(snake_case    ,   (float, int)			), f'b should be float or integer your input : {b}'
   assert (
       isinstance(snake_case    ,   snake_case			) and precision > 0
   ), f'precision should be positive integer your input : {precision}'

   # just applying the formula of simpson for approximate integration written in
   # mentioned article in first comment of this file and above this function

   __lowerCamelCase:					List[str]	 =						(b - a) / N_STEPS
   __lowerCamelCase:					Optional[Any]	 =						function(snake_case			) + function(snake_case			)

   for i in range(1    ,   snake_case			):
      __lowerCamelCase:					Dict	 =						a + h * i
      result += function(snake_case			) * (4 if i % 2 else 2)

   result *= h / 3
   return round(snake_case    ,   snake_case			)


if __name__ == "__main__":
   import doctest

   doctest.testmod()


