




__magic_name__     :     int  							=					float("""inf""")





class 						SCREAMING_SNAKE_CASE__		:
     def __init__(	self  :		List[Any]					,	__lowerCamelCase  :		List[str]	):



       """simple docstring"""
       lowerCAmelCase__								=			[0] * n
       lowerCAmelCase__								=			[0] * n
       lowerCAmelCase__								=			[0] * n
       lowerCAmelCase__								=			[[] for _ in range(SCREAMING_SNAKE_CASE_	)]
     def 					A__			(	self  :		str					,	__lowerCamelCase  :		Any					,	__lowerCamelCase  :		Tuple					,	__lowerCamelCase  :		Dict					,	__lowerCamelCase  :		int=0	):



       """simple docstring"""
       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  :		Optional[Any]					,	__lowerCamelCase  :		List[Any]					,	__lowerCamelCase  :		Union[str, Any]					,	__lowerCamelCase  :		Optional[int]	):



       """simple docstring"""
       if vertex == sink or not flow:
         return flow

       for i in range(self.ptr[vertex]					,	len(self.adj[vertex]	)	):
         lowerCAmelCase__								=			self.adj[vertex][i]
         if self.lvl[e[0]] == self.lvl[vertex] + 1:
           lowerCAmelCase__								=			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
         lowerCAmelCase__								=			self.ptr[vertex] + 1
       return 0



     def 					A__			(	self  :		Optional[int]					,	__lowerCamelCase  :		str					,	__lowerCamelCase  :		str	):



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

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

           if not self.lvl[sink]:
             break

       return flow



__magic_name__     :     Dict  							=					Dinic(10)
__magic_name__     :     int  							=					0
__magic_name__     :     int  							=					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))







def 		a_       (   __lowerCAmelCase      ,   __lowerCAmelCase							):
  assert isinstance(__lowerCAmelCase      ,   __lowerCAmelCase							), F"""The input value of [set_a={set_a}] is not a set"""
  assert isinstance(__lowerCAmelCase      ,   __lowerCAmelCase							), F"""The input value of [set_b={set_b}] is not a set"""

  return {a + b for a in set_a for b in set_b}


if __name__ == "__main__":
      from doctest import testmod

      testmod()

