



from __future__ import annotations
def 	snake_case__       (					__lowercase							,     __lowercase       )		->		int:







						"""simple docstring"""

						print(F'Vertex\tShortest Distance from vertex {src}'       )
						for i, d in enumerate(__lowercase       ):
												print(F'{i}\t\t{d}'       )
def 	snake_case__       (					__lowercase							,     __lowercase							,     __lowercase       )		->		Union[str, Any]:







						"""simple docstring"""

						for j in range(__lowercase       ):
												A__    ,       A__    ,       A__	:							str						    = (graph[j][k] for k in ["src", "dst", "weight"])
												if distance[u] != float("inf"       ) and distance[u] + w < distance[v]:
																		return True
						return False
def 	snake_case__       (					__lowercase							,     __lowercase							,     __lowercase							,     __lowercase       )		->		list[float]:







						"""simple docstring"""

						A__	:							List[str]						    = [float("inf"       )] * vertex_count
						A__	:							str						    = 0.0

						for _ in range(vertex_count - 1       ):
												for j in range(__lowercase       ):
																		A__    ,       A__    ,       A__	:							Any						    = (graph[j][k] for k in ["src", "dst", "weight"])

																		if distance[u] != float("inf"       ) and distance[u] + w < distance[v]:
																								A__	:							int						    = distance[u] + w

						A__	:							Optional[Any]						    = check_negative_cycle(__lowercase							,     __lowercase							,     __lowercase       )
						if negative_cycle_exists:
												raise Exception("Negative cycle found"       )

						return distance


if __name__ == "__main__":
		import doctest

		doctest.testmod()

		snake_case    :						Tuple  =						int(input('Enter number of vertices: ').strip())
		snake_case    :						List[str]  =						int(input('Enter number of edges: ').strip())

		snake_case    :						list[dict[str, int]]  =						[{} for _ in range(E)]

		for i in range(E):
				print('Edge ', i + 1)
				snake_case ,       snake_case ,       snake_case    :						Optional[Any]  =						(
				    int(x)
				    for x in input('Enter source, destination, weight: ').strip().split(' ')
				)
				snake_case    :						str  =						{'src': src, 'dst': dest, 'weight': weight}

		snake_case    :						Tuple  =						int(input('\nEnter shortest path source:').strip())
		snake_case    :						Union[str, Any]  =						bellman_ford(graph, V, E, source)
		print_distance(shortest_distance, 0)




from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt
def 	snake_case__       (					__lowercase       )		->		bool:







						"""simple docstring"""

						A__	:							int						    = int(number**0.5       )
						return number == sq * sq
def 	snake_case__       (					__lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase       )		->		tuple[int, int]:







						"""simple docstring"""

						A__	:							int						    = x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
						A__	:							int						    = x_den * y_den * z_den
						A__	:							int						    = gcd(__lowercase							,     __lowercase       )
						top //= hcf
						bottom //= hcf
						return top, bottom
def 	snake_case__       (					__lowercase = 3_5       )		->		int:







						"""simple docstring"""

						A__	:							set						    = set()
						A__	:							int
						A__	:							Fraction						    = Fraction(0       )
						A__	:							tuple[int, int]

						for x_num in range(1							,     order + 1       ):
												for x_den in range(x_num + 1							,     order + 1       ):
																		for y_num in range(1							,     order + 1       ):
																								for y_den in range(y_num + 1							,     order + 1       ):
																														# n=1
																														A__	:							Any						    = x_num * y_den + x_den * y_num
																														A__	:							List[Any]						    = x_den * y_den
																														A__	:							List[Any]						    = gcd(__lowercase							,     __lowercase       )
																														z_num //= hcf
																														z_den //= hcf
																														if 0 < z_num < z_den <= order:
																																				A__	:							List[Any]						    = add_three(
																																				    __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase       )
																																				unique_s.add(__lowercase       )

																														# n=2
																														A__	:							Any						    = (
																														    x_num * x_num * y_den * y_den + x_den * x_den * y_num * y_num
																														)
																														A__	:							Optional[int]						    = x_den * x_den * y_den * y_den
																														if is_sq(__lowercase       ) and is_sq(__lowercase       ):
																																				A__	:							Union[str, Any]						    = int(sqrt(__lowercase       )       )
																																				A__	:							int						    = int(sqrt(__lowercase       )       )
																																				A__	:							Any						    = gcd(__lowercase							,     __lowercase       )
																																				z_num //= hcf
																																				z_den //= hcf
																																				if 0 < z_num < z_den <= order:
																																										A__	:							List[Any]						    = add_three(
																																										    __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase       )
																																										unique_s.add(__lowercase       )

                    # n=-1
																														A__	:							Tuple						    = x_num * y_num
																														A__	:							int						    = x_den * y_num + x_num * y_den
																														A__	:							List[str]						    = gcd(__lowercase							,     __lowercase       )
																														z_num //= hcf
																														z_den //= hcf
																														if 0 < z_num < z_den <= order:
																																				A__	:							str						    = add_three(
																																				    __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase       )
																																				unique_s.add(__lowercase       )

																														# n=2
																														A__	:							Any						    = x_num * x_num * y_num * y_num
																														A__	:							List[str]						    = (
																														    x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
																														)
																														if is_sq(__lowercase       ) and is_sq(__lowercase       ):
																																				A__	:							Optional[int]						    = int(sqrt(__lowercase       )       )
																																				A__	:							List[Any]						    = int(sqrt(__lowercase       )       )
																																				A__	:							Union[str, Any]						    = gcd(__lowercase							,     __lowercase       )
																																				z_num //= hcf
																																				z_den //= hcf
																																				if 0 < z_num < z_den <= order:
																																										A__	:							Optional[Any]						    = add_three(
																																										    __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase							,     __lowercase       )
																																										unique_s.add(__lowercase       )

						for num, den in unique_s:
												total += Fraction(__lowercase							,     __lowercase       )

						return total.denominator + total.numerator


if __name__ == "__main__":
		print(f"""{solution() = }""")