




'''simple docstring'''

from __future__ import annotations

from typing import Any






class 		a							:


				def __init__(						self       :   Any			,							lowercase_       :   int = 6   ):
									snake_case_		     =							None
									snake_case_		     =							None
									self.create_linked_list(lowercase_   )


				def     A_					(						self       :   Dict			,							lowercase_       :   int   ):
									snake_case_		     =							Node()
									snake_case_		     =							current_node
									snake_case_		     =							current_node
									snake_case_		     =							current_node
									for _ in range(1			,							lowercase_   ):
														snake_case_		     =							Node()
														snake_case_		     =							current_node
														snake_case_		     =							previous_node
														snake_case_		     =							current_node
									snake_case_		     =							self.front
									snake_case_		     =							previous_node


				def     A_					(						self       :   List[Any]   ):
									return (
									    self.front == self.rear
									    and self.front is not None
									    and self.front.data is None
									)


				def     A_					(						self       :   Any   ):
									self.check_can_perform_operation()
									return self.front.data if self.front else None


				def     A_					(						self       :   Optional[Any]			,							lowercase_       :   Any   ):
									if self.rear is None:
														return

									self.check_is_full()
									if not self.is_empty():
														snake_case_		     =							self.rear.next
									if self.rear:
														snake_case_		     =							data


				def     A_					(						self       :   Optional[int]   ):
									self.check_can_perform_operation()
									if self.rear is None or self.front is None:
														return None
									if self.front == self.rear:
														snake_case_		     =							self.front.data
														snake_case_		     =							None
														return data

									snake_case_		     =							self.front
									snake_case_		     =							old_front.next
									snake_case_		     =							old_front.data
									snake_case_		     =							None
									return data


				def     A_					(						self       :   str   ):
									if self.is_empty():
														raise Exception('''Empty Queue'''   )


				def     A_					(						self       :   Tuple   ):
									if self.rear and self.rear.next == self.front:
														raise Exception('''Full Queue'''   )







class 		a							:


				def __init__(						self       :   Tuple   ):
									snake_case_		     =							None
									snake_case_		     =							None
									snake_case_		     =							None


if __name__ == "__main__":
							import doctest

							doctest.testmod()







'''simple docstring'''

def 						__magic_name__       (      __UpperCAmelCase, __UpperCAmelCase, __UpperCAmelCase, __UpperCAmelCase      )						->   Optional[Any]:

					'''simple docstring'''

					snake_case_		     =							[False] * len(__UpperCAmelCase      )
					snake_case_		     =							[]
					queue.append(__UpperCAmelCase      )
					snake_case_		     =							True

					while queue:
										snake_case_		     =							queue.pop(0      )
										for ind in range(len(graph[u]      )      ):
															if visited[ind] is False and graph[u][ind] > 0:
																				queue.append(__UpperCAmelCase      )
																				snake_case_		     =							True
																				snake_case_		     =							u

					return visited[t]


def 						__magic_name__       (      __UpperCAmelCase, __UpperCAmelCase, __UpperCAmelCase      )						->   Tuple:

					'''simple docstring'''

					snake_case_		     =							[-1] * (len(__UpperCAmelCase      ))
					snake_case_		     =							0
					while bfs(__UpperCAmelCase, __UpperCAmelCase, __UpperCAmelCase, __UpperCAmelCase      ):
										snake_case_		     =							float('''Inf'''      )
										snake_case_		     =							sink

										while s != source:
															# Find the minimum value in select path
															snake_case_		     =							min(__UpperCAmelCase, graph[parent[s]][s]      )
															snake_case_		     =							parent[s]

										max_flow += path_flow
										snake_case_		     =							sink

										while v != source:
															snake_case_		     =							parent[v]
															graph[u][v] -= path_flow
															graph[v][u] += path_flow
															snake_case_		     =							parent[v]
					return max_flow


a    :							List[Any]										=    [
    [0, 16, 13, 0, 0, 0],
    [0, 0, 10, 12, 0, 0],
    [0, 4, 0, 0, 14, 0],
    [0, 0, 9, 0, 0, 20],
    [0, 0, 0, 7, 0, 4],
    [0, 0, 0, 0, 0, 0],
]

a						,a    :							int										=    0, 5

print(ford_fulkerson(graph, source, sink))

