"""simple docstring"""







_a	:	Optional[int]=					float("inf")

class 						UpperCamelCase     :



				def __init__(self							: int      ,    _A							: Tuple)       ->      Optional[int]:
					__snake_case     :				Tuple 						=					[0] * n
					__snake_case     :				int 						=					[0] * n
					__snake_case     :				List[str] 						=					[0] * n
					__snake_case     :				List[Any] 						=					[[] for _ in range(__lowerCAmelCase)]



				def    _lowercase	(self							: Union[str, Any]      ,    _A							: Any      ,    _A							: Optional[int]      ,    _A							: Union[str, Any]      ,    _A							: Optional[Any]=0)       ->      Dict:
					self.adj[a].append([b, len(self.adj[b]), c, 0])
					self.adj[b].append([a, len(self.adj[a]) - 1, rcap, 0])



				def    _lowercase	(self							: Optional[Any]      ,    _A							: List[str]      ,    _A							: int      ,    _A							: Optional[Any])       ->      Dict:


					if vertex == sink or not flow:
						return flow

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






				def    _lowercase	(self							: List[Any]      ,    _A							: List[str]      ,    _A							: Tuple)       ->      Union[str, Any]:
					__snake_case     :				Optional[int] 						=					0, source
					for l in range(31):  # noqa: E741  l = 30 maybe faster for random data
						while True:
							__snake_case     :				Any 						=					[0] * len(self.q), [0] * len(self.q)
							__snake_case     :				Dict 						=					0, 1, 1
							while qi < qe and not self.lvl[sink]:
								__snake_case     :				Any 						=					self.q[qi]
								qi += 1
								for e in self.adj[v]:
									if not self.lvl[e[0]] and (e[2] - e[3]) >> (30 - l):
										__snake_case     :				List[str] 						=					e[0]
										qe += 1
										__snake_case     :				Optional[int] 						=					self.lvl[v] + 1

							__snake_case     :				Any 						=					self.depth_first_search(__lowerCAmelCase      ,    __lowerCAmelCase      ,    __lowerCAmelCase)
							while p:
								flow += p
								__snake_case     :				List[Any] 						=					self.depth_first_search(__lowerCAmelCase      ,    __lowerCAmelCase      ,    __lowerCAmelCase)

							if not self.lvl[sink]:
								break

					return flow







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











'''simple docstring'''





from __future__ import annotations

import sys





def UpperCAmelCase    (       UpperCAmelCase_   ,	UpperCAmelCase_						):
    # base cases
    if abs(UpperCAmelCase_						) == 1:
        return a, 0
    elif abs(UpperCAmelCase_						) == 1:
        return 0, b

    _a       , _a				:							List[Any]							       =      a, b
    _a       , _a				:							str							       =      1, 0
    _a       , _a				:							Union[str, Any]							       =      0, 1

    while remainder != 0:
        _a				:							List[Any]							       =      old_remainder // remainder
        _a       , _a				:							str							       =      remainder, old_remainder - quotient * remainder
        _a       , _a				:							Optional[Any]							       =      coeff_a, old_coeff_a - quotient * coeff_a
        _a       , _a				:							Tuple							       =      coeff_b, old_coeff_b - quotient * coeff_b

    # sign correction for negative numbers
    if a < 0:
        _a				:							Tuple							       =      -old_coeff_a
    if b < 0:
        _a				:							Any							       =      -old_coeff_b

    return old_coeff_a, old_coeff_b





def UpperCAmelCase    (       ):
    if len(sys.argv						) < 3:
        print("""2 integer arguments required"""						)
        return 1
    _a				:							Union[str, Any]							       =      int(sys.argv[1]						)
    _a				:							Any							       =      int(sys.argv[2]						)
    print(extended_euclidean_algorithm(UpperCAmelCase_   ,	UpperCAmelCase_						)						)
    return 0


if __name__ == "__main__":
  raise SystemExit(main())


