'''simple docstring'''






from __future__ import annotations

from collections import deque
from collections.abc import Iterator
from dataclasses import dataclass







@dataclass
class lowercase_       :







   """simple docstring"""

   __lowerCAmelCase         =   42
   __lowerCAmelCase         =   42







class lowercase_       :







   """simple docstring"""

   def __init__(      self      :			Optional[int], UpperCamelCase__      :			int     )  ->			Any:
        _A    		=  [[] for _ in range(UpperCamelCase__     )]
        _A    		=  size
   def __getitem__(      self      :			Dict, UpperCamelCase__      :			int     )  ->			Iterator[Edge]:
        return iter(self._graph[vertex]     )
   @property
   def 	__UpperCAmelCase   (      self      :			List[str]     )  ->			List[Any]:
        return self._size
   def 	__UpperCAmelCase   (      self      :			str, UpperCamelCase__      :			int, UpperCamelCase__      :			int, UpperCamelCase__      :			int     )  ->			List[Any]:
        if weight not in (0, 1):
             raise ValueError('Edge weight must be either 0 or 1.'     )

        if to_vertex < 0 or to_vertex >= self.size:
             raise ValueError('Vertex indexes must be in [0; size).'     )

        self._graph[from_vertex].append(Edge(UpperCamelCase__, UpperCamelCase__     )     )

   def 	__UpperCAmelCase   (      self      :			List[str], UpperCamelCase__      :			int, UpperCamelCase__      :			int     )  ->			int | None:
        _A    		=  deque([start_vertex]     )
        _A    		=  [None] * self.size
        _A    		=  0

        while queue:
             _A    		=  queue.popleft()
             _A    		=  distances[current_vertex]
             if current_distance is None:
                  continue

             for edge in self[current_vertex]:
                  _A    		=  current_distance + edge.weight
                  _A    		=  distances[edge.destination_vertex]
                  if (
                      isinstance(UpperCamelCase__, UpperCamelCase__     )
                      and new_distance >= dest_vertex_distance
                  ):
                       continue
                  _A    		=  new_distance
                  if edge.weight == 0:
                       queue.appendleft(edge.destination_vertex     )
                  else:
                       queue.append(edge.destination_vertex     )

        if distances[finish_vertex] is None:
             raise ValueError('No path from start_vertex to finish_vertex.'     )

        return distances[finish_vertex]


if __name__ == "__main__":
   import doctest

   doctest.testmod()




'''simple docstring'''






import math





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			int				):
     _A    		=  []
     _A    		=  2
     _A    		=  int(math.sqrt(__snake_case				)				)  # Size of every segment
     _A    		=  [True] * (end + 1)
     _A    		=  []

     while start <= end:
          if temp[start] is True:
               in_prime.append(__snake_case				)
               for i in range(start * start   ,		end + 1   ,		__snake_case				):
                    _A    		=  False
          start += 1
     prime += in_prime

     _A    		=  end + 1
     _A    		=  min(2 * end   ,		__snake_case				)

     while low <= n:
          _A    		=  [True] * (high - low + 1)
          for each in in_prime:
               _A    		=  math.floor(low / each				) * each
               if t < low:
                    t += each

               for j in range(__snake_case   ,		high + 1   ,		__snake_case				):
                    _A    		=  False

          for j in range(len(__snake_case				)				):
               if temp[j] is True:
                    prime.append(j + low				)

          _A    		=  high + 1
          _A    		=  min(high + end   ,		__snake_case				)

     return prime
print(sieve(10**6))



