



from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt






def 					__lowerCAmelCase		(  __lowerCamelCase	:    int	)  ->						bool:
					__lowerCAmelCase	   =int(number**0.5	)
					return number == sq * sq






def 					__lowerCAmelCase		(  __lowerCamelCase	:    int				,   __lowerCamelCase	:    int				,   __lowerCamelCase	:    int				,   __lowerCamelCase	:    int				,   __lowerCamelCase	:    int				,   __lowerCamelCase	:    int	)  ->						tuple[int, int]:
					__lowerCAmelCase	   =x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
					__lowerCAmelCase	   =x_den * y_den * z_den
					__lowerCAmelCase	   =gcd(__lowerCamelCase				,   __lowerCamelCase	)
					top //= hcf
					bottom //= hcf
					return top, bottom






def 					__lowerCAmelCase		(  __lowerCamelCase	:    int = 35	)  ->						int:
					__lowerCAmelCase	   =set()
					__lowerCAmelCase	   =42
					__lowerCAmelCase	   =Fraction(0	)
					__lowerCAmelCase	   =42

					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
																									__lowerCAmelCase	   =x_num * y_den + x_den * y_num
																									__lowerCAmelCase	   =x_den * y_den
																									__lowerCAmelCase	   =gcd(__lowerCamelCase				,   __lowerCamelCase	)
																									z_num //= hcf
																									z_den //= hcf
																									if 0 < z_num < z_den <= order:
																														__lowerCAmelCase	   =add_three(
																														    __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase	)
																														unique_s.add(__lowerCamelCase	)

																									# n=2
																									__lowerCAmelCase	   =(
																									    x_num * x_num * y_den * y_den + x_den * x_den * y_num * y_num
																									)
																									__lowerCAmelCase	   =x_den * x_den * y_den * y_den
																									if is_sq(__lowerCamelCase	) and is_sq(__lowerCamelCase	):
																														__lowerCAmelCase	   =int(sqrt(__lowerCamelCase	)	)
																														__lowerCAmelCase	   =int(sqrt(__lowerCamelCase	)	)
																														__lowerCAmelCase	   =gcd(__lowerCamelCase				,   __lowerCamelCase	)
																														z_num //= hcf
																														z_den //= hcf
																														if 0 < z_num < z_den <= order:
																																			__lowerCAmelCase	   =add_three(
																																			    __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase	)
																																			unique_s.add(__lowerCamelCase	)

                    # n=-1
																									__lowerCAmelCase	   =x_num * y_num
																									__lowerCAmelCase	   =x_den * y_num + x_num * y_den
																									__lowerCAmelCase	   =gcd(__lowerCamelCase				,   __lowerCamelCase	)
																									z_num //= hcf
																									z_den //= hcf
																									if 0 < z_num < z_den <= order:
																														__lowerCAmelCase	   =add_three(
																														    __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase	)
																														unique_s.add(__lowerCamelCase	)

																									# n=2
																									__lowerCAmelCase	   =x_num * x_num * y_num * y_num
																									__lowerCAmelCase	   =(
																									    x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
																									)
																									if is_sq(__lowerCamelCase	) and is_sq(__lowerCamelCase	):
																														__lowerCAmelCase	   =int(sqrt(__lowerCamelCase	)	)
																														__lowerCAmelCase	   =int(sqrt(__lowerCamelCase	)	)
																														__lowerCAmelCase	   =gcd(__lowerCamelCase				,   __lowerCamelCase	)
																														z_num //= hcf
																														z_den //= hcf
																														if 0 < z_num < z_den <= order:
																																			__lowerCAmelCase	   =add_three(
																																			    __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase				,   __lowerCamelCase	)
																																			unique_s.add(__lowerCamelCase	)

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

					return total.denominator + total.numerator


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









import math

from numpy import inf
from scipy.integrate import quad






def 					__lowerCAmelCase		(  __lowerCamelCase	:    float	)  ->						float:
					if num <= 0:
										raise ValueError("""math domain error"""	)

					return quad(__lowerCamelCase				,   0				,   __lowerCamelCase				,   args=(__lowerCamelCase)	)[0]






def 					__lowerCAmelCase		(  __lowerCamelCase	:    float				,   __lowerCamelCase	:    float	)  ->						float:
					return math.pow(__lowerCamelCase				,   z - 1	) * math.exp(-x	)


if __name__ == "__main__":
				from doctest import testmod

				testmod()




