"""simple docstring"""



class      _A	:




    """simple docstring"""




    def __init__(		self							:     int	,      A_							:     Any	,      A_							:     Optional[Any]	,      A_							:     Tuple    )    ->       Optional[Any]:
         __snake_case				=							None
         __snake_case				=							None
         __snake_case				=							graph

         self._normalize_graph(A_	,      A_    )
         __snake_case				=							len(A_    )
         __snake_case				=							None
    def  lowercase					(		self							:     Dict	,      A_							:     Union[str, Any]	,      A_							:     str    )    ->       int:
         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  lowercase					(		self							:     str    )    ->       Tuple:
         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  lowercase					(		self							:     Dict	,      A_							:     int    )    ->       int:
         __snake_case				=							algorithm(self    )






class      _A	:




    """simple docstring"""




    def __init__(		self							:     List[str]	,      A_							:     List[Any]    )    ->       str:
         __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  lowercase					(		self							:     Tuple    )    ->       Union[str, Any]:
         if not self.executed:
              self._algorithm()
              __snake_case				=							True







    def  lowercase					(		self							:     Any    )    ->       Tuple:
         pass






class      _A	(						_UpperCAmelCase					):




    """simple docstring"""




    def __init__(		self							:     Dict	,      A_							:     int    )    ->       Tuple:
         super().__init__(A_    )
         # use this to save your result
         __snake_case				=							-1







    def  lowercase					(		self							:     Tuple    )    ->       Optional[Any]:
         if not self.executed:
              raise Exception('''You should execute algorithm before using its result!'''    )

         return self.maximum_flow






class      _A	(						_UpperCAmelCase					):




    """simple docstring"""




    def __init__(		self							:     Tuple	,      A_							:     List[str]    )    ->       Optional[int]:
         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  lowercase					(		self							:     Dict    )    ->       Tuple:
         __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  lowercase					(		self							:     str	,      A_							:     int    )    ->       str:
         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  lowercase					(		self							:     List[Any]	,      A_							:     Optional[Any]	,      A_							:     Optional[int]    )    ->       int:
         __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  lowercase					(		self							:     List[Any]	,      A_							:     Optional[int]    )    ->       str:
         __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__":
       __lowercase		:		str														=							[0]
       __lowercase		:		Dict														=							[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],
       # ]
       __lowercase		:		List[Any]														=							[[0, 7, 0, 0], [0, 0, 6, 0], [0, 0, 0, 8], [9, 0, 0, 0]]

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

       print(F"""maximum flow is {maximum_flow}""")
"""simple docstring"""



def    SCREAMING_SNAKE_CASE       (     snake_case):
     return 1 if digit in (0, 1) else (digit * factorial(digit - 1))





def    SCREAMING_SNAKE_CASE       (     snake_case):
     __snake_case				=							0
     __snake_case				=							number
     while duplicate > 0:
          __snake_case		,	__snake_case				=							divmod(snake_case,      10)
          fact_sum += factorial(snake_case)
     return fact_sum == number


if __name__ == "__main__":
       print("Program to check whether a number is a Krisnamurthy Number or not.")
       __lowercase		:		Optional[int]														=							int(input("Enter number: ").strip())
       print(
           F"""{number} is {'' if krishnamurthy(number) else 'not '}a Krishnamurthy Number."""
       )