from __future__ import annotations

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



@dataclass
class 					lowerCAmelCase_      :



				"""simple docstring"""
				_lowerCAmelCase       :      int
				_lowerCAmelCase       :      int





class 					lowerCAmelCase_      :



				"""simple docstring"""

				def __init__(			self						,      lowerCAmelCase      ):






										"""simple docstring"""

										snake_case        =     [[] for _ in range(lowerCAmelCase      )]
										snake_case        =     size

				def __getitem__(			self						,      lowerCAmelCase      ):






										"""simple docstring"""

										return iter(self._graph[vertex]      )

				@property
				def 						snake_case	(			self      ):






										"""simple docstring"""

										return self._size

				def 						snake_case	(			self						,      lowerCAmelCase						,      lowerCAmelCase						,      lowerCAmelCase      ):






										"""simple docstring"""

										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(lowerCAmelCase						,      lowerCAmelCase      )      )

				def 						snake_case	(			self						,      lowerCAmelCase						,      lowerCAmelCase      ):






										"""simple docstring"""

										snake_case        =     deque([start_vertex]      )
										snake_case        =     [None] * self.size
										snake_case        =     0

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

																for edge in self[current_vertex]:
																						snake_case        =     current_distance + edge.weight
																						snake_case        =     distances[edge.destination_vertex]
																						if (
																						    isinstance(lowerCAmelCase						,      lowerCAmelCase      )
																						    and new_distance >= dest_vertex_distance
																						):
																												continue
																						snake_case        =     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"""
SCREAMING_SNAKE_CASE__   =					{str(digit): digit**5 for digit in range(10)}





def 				lowerCAmelCase__      (     _UpperCamelCase    :			int   )   ->			int:





						"""simple docstring"""






						return sum(DIGITS_FIFTH_POWER[digit] for digit in str(_UpperCamelCase   )   )





def 				lowerCAmelCase__      (     )   ->			int:





						"""simple docstring"""






						return sum(
						    number
						    for number in range(1_0_0_0	,     1_0_0_0_0_0_0   )
						    if number == digits_fifth_powers_sum(_UpperCamelCase   )   )


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


