import colorsys

from PIL import Image  # type: ignore





def        lowercase(     UpperCamelCase_				, UpperCamelCase_				, UpperCamelCase_    )						->     float:







 '''simple docstring'''
 UpperCamelCase          =	x
 UpperCamelCase          =	y
 for step in range(lowerCamelCase_    ):  # noqa: B007
  UpperCamelCase          =	a * a - b * b + x
  UpperCamelCase          =	2 * a * b + y
  UpperCamelCase          =	a_new

  # divergence happens for all complex number with an absolute value
  # greater than 4
  if a * a + b * b > 4:
   break
 return step / (max_step - 1)





def        lowercase(     UpperCamelCase_    )						->     tuple:







 '''simple docstring'''
 if distance == 1:
  return (0, 0, 0)
 else:
  return (255, 255, 255)





def        lowercase(     UpperCamelCase_    )						->     tuple:







 '''simple docstring'''
 if distance == 1:
  return (0, 0, 0)
 else:
  return tuple(round(i * 255    ) for i in colorsys.hsv_to_rgb(lowerCamelCase_				, 1				, 1    )    )





def        lowercase(     UpperCamelCase_ = 800				, UpperCamelCase_ = 600				, UpperCamelCase_ = -0.6				, UpperCamelCase_ = 0				, UpperCamelCase_ = 3.2				, UpperCamelCase_ = 50				, UpperCamelCase_ = True				, )						->     Image.Image:







 '''simple docstring'''
 UpperCamelCase          =	Image.new("""RGB"""				, (image_width, image_height)    )
 UpperCamelCase          =	img.load()

 # loop through the image-coordinates
 for image_x in range(lowerCamelCase_    ):
  for image_y in range(lowerCamelCase_    ):
   # determine the figure-coordinates based on the image-coordinates
   UpperCamelCase          =	figure_width / image_width * image_height
   UpperCamelCase          =	figure_center_x + (image_x / image_width - 0.5) * figure_width
   UpperCamelCase          =	figure_center_y + (image_y / image_height - 0.5) * figure_height

   UpperCamelCase          =	get_distance(lowerCamelCase_				, lowerCamelCase_				, lowerCamelCase_    )

   # color the corresponding pixel based on the selected coloring-function
   if use_distance_color_coding:
    UpperCamelCase          =	get_color_coded_rgb(lowerCamelCase_    )
   else:
    UpperCamelCase          =	get_black_and_white_rgb(lowerCamelCase_    )

 return img


if __name__ == "__main__":
     import doctest

     doctest.testmod()

     # colored version, full figure
     _SCREAMING_SNAKE_CASE      						=	get_image()

     # uncomment for colored version, different section, zoomed in
     # img = get_image(figure_center_x = -0.6, figure_center_y = -0.4,
     # figure_width = 0.8)

     # uncomment for black and white version, full figure
     # img = get_image(use_distance_color_coding = False)

     # uncomment to save the image
     # img.save("mandelbrot.png")

     img.show()




from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt



def 				UpperCamelCase_(      lowerCamelCase_ )    ->						bool:
    _lowercase       :							int      		=		int(number**0.5 )
    return number == sq * sq



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



def 				UpperCamelCase_(      lowerCamelCase_ = 35 )    ->						int:
    _lowercase       :							set      		=		set()
    _lowercase       :							int
    _lowercase       :							Fraction      		=		Fraction(0 )
    _lowercase       :							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
                    _lowercase       :							int      		=		x_num * y_den + x_den * y_num
                    _lowercase       :							int      		=		x_den * y_den
                    _lowercase       :							str      		=		gcd(lowerCamelCase_							, lowerCamelCase_ )
                    z_num //= hcf
                    z_den //= hcf
                    if 0 < z_num < z_den <= order:
                        _lowercase       :							List[Any]      		=		add_three(
                            lowerCamelCase_							, lowerCamelCase_							, lowerCamelCase_							, lowerCamelCase_							, lowerCamelCase_							, lowerCamelCase_ )
                        unique_s.add(lowerCamelCase_ )

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

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

                    # n=2
                    _lowercase       :							str      		=		x_num * x_num * y_num * y_num
                    _lowercase       :							Optional[Any]      		=		(
                        x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
                    )
                    if is_sq(lowerCamelCase_ ) and is_sq(lowerCamelCase_ ):
                        _lowercase       :							Tuple      		=		int(sqrt(lowerCamelCase_ ) )
                        _lowercase       :							List[str]      		=		int(sqrt(lowerCamelCase_ ) )
                        _lowercase       :							Union[str, Any]      		=		gcd(lowerCamelCase_							, lowerCamelCase_ )
                        z_num //= hcf
                        z_den //= hcf
                        if 0 < z_num < z_den <= order:
                            _lowercase       :							Tuple      		=		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() = }")


