
__lowerCAmelCase   :     Union[str, Any]      =						float("inf")


class   __lowerCAmelCase		:



      """simple docstring"""







      def __init__( self						:    List[Any]			,    _snake_case						:    Optional[Any]			):
          __lowercase						:     Optional[Any]		      =    [0] * n
          __lowercase						:     Union[str, Any]		      =    [0] * n
          __lowercase						:     Dict		      =    [0] * n
          __lowercase						:     Any		      =    [[] for _ in range(_snake_case			)]




      def 						snake_case_     ( self						:    str			,    _snake_case						:    Tuple			,    _snake_case						:    Optional[int]			,    _snake_case						:    List[str]			,    _snake_case						:    Tuple=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 						snake_case_     ( self						:    Any			,    _snake_case						:    List[Any]			,    _snake_case						:    str			,    _snake_case						:    Tuple			):
          if vertex == sink or not flow:
              return flow

          for i in range(self.ptr[vertex]			,    len(self.adj[vertex]			)			):
              __lowercase						:     Union[str, Any]		      =    self.adj[vertex][i]
              if self.lvl[e[0]] == self.lvl[vertex] + 1:
                  __lowercase						:     Optional[int]		      =    self.depth_first_search(e[0]			,    _snake_case			,    min(_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						:     List[str]		      =    self.ptr[vertex] + 1
          return 0




      def 						snake_case_     ( self						:    Optional[int]			,    _snake_case						:    int			,    _snake_case						:    int			):
          __lowercase						:     str		      =    0, source
          for l in range(31			):  # noqa: E741  l = 30 maybe faster for random data
              while True:
                  __lowercase						:     Optional[Any]		      =    [0] * len(self.q			), [0] * len(self.q			)
                  __lowercase						:     Union[str, Any]		      =    0, 1, 1
                  while qi < qe and not self.lvl[sink]:
                      __lowercase						:     List[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):
                              __lowercase						:     Optional[Any]		      =    e[0]
                              qe += 1
                              __lowercase						:     List[Any]		      =    self.lvl[v] + 1

                  __lowercase						:     Union[str, Any]		      =    self.depth_first_search(_snake_case			,    _snake_case			,    _snake_case			)
                  while p:
                      flow += p
                      __lowercase						:     List[str]		      =    self.depth_first_search(_snake_case			,    _snake_case			,    _snake_case			)

                  if not self.lvl[sink]:
                      break

          return flow






__lowerCAmelCase   :     List[Any]      =						Dinic(10)
__lowerCAmelCase   :     Any      =						0
__lowerCAmelCase   :     List[str]      =						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))




from __future__ import annotations

from collections import Counter


def       UpperCAmelCase_					(  __lowerCAmelCase		)	->  list[int]:
    __lowercase						:     Any		      =    [True] * n
    __lowercase						:     str		      =    False
    __lowercase						:     int		      =    False
    __lowercase						:     List[Any]		      =    True

    for i in range(3		,   int(n**0.5 + 1		)		,   2		):
        __lowercase						:     List[str]		      =    i * 2
        while index < n:
            __lowercase						:     List[Any]		      =    False
            __lowercase						:     Dict		      =    index + i

    __lowercase						:     Tuple		      =    [2]

    for i in range(3		,   __lowerCAmelCase		,   2		):
        if is_prime[i]:
            primes.append(__lowerCAmelCase		)

    return primes


def       UpperCAmelCase_					(  __lowerCAmelCase		)	->  list[list[int]]:
    __lowercase						:     Optional[int]		      =    str(__lowerCAmelCase		)
    __lowercase						:     List[str]		      =    []
    __lowercase						:     int		      =    ['''0''', '''1''', '''2''', '''3''', '''4''', '''5''', '''6''', '''7''', '''8''', '''9''']

    for duplicate in Counter(__lowerCAmelCase		) - Counter(set(__lowerCAmelCase		)		):
        __lowercase						:     Union[str, Any]		      =    [int(number_str.replace(__lowerCAmelCase		,   __lowerCAmelCase		)		) for digit in digits]
        replacements.append(__lowerCAmelCase		)

    return replacements


def       UpperCAmelCase_					(  __lowerCAmelCase = 8		)	->  int:
    __lowercase						:     Tuple		      =    set()

    # Filter primes with less than 3 replaceable digits
    __lowercase						:     int		      =    {
        x for x in set(prime_sieve(1_000_000		)		) if len(str(__lowerCAmelCase		)		) - len(set(str(__lowerCAmelCase		)		)		) >= 3
    }

    for prime in primes:
        if prime in numbers_checked:
            continue

        __lowercase						:     str		      =    digit_replacements(__lowerCAmelCase		)

        for family in replacements:
            numbers_checked.update(__lowerCAmelCase		)
            __lowercase						:     List[Any]		      =    primes.intersection(__lowerCAmelCase		)

            if len(__lowerCAmelCase		) != family_length:
                continue

            return min(__lowerCAmelCase		)

    return -1


if __name__ == "__main__":
 print(solution())


