


'''simple docstring'''



from importlib import import_module

from .logging import get_logger


__UpperCAmelCase    :int				       =     get_logger(__name__)



class 			a       :


     """simple docstring"""






     def __init__(       self  :	Optional[int]							,				snake_case  :	Tuple							,				snake_case  :	Tuple=None    )		->							Union[str, Any]:
          __UpperCAmelCase			:				List[Any]													=    attrs or []
          if module is not None:
               for key in module.__dict__:
                    if key in attrs or not key.startswith('''__'''    ):
                         setattr(self							,				snake_case							,				getattr(snake_case							,				snake_case    )    )
          __UpperCAmelCase			:				Optional[Any]													=    module._original_module if isinstance(snake_case							,				_PatchedModuleObj    ) else module



class 			a       :


     """simple docstring"""






     SCREAMING_SNAKE_CASE :				Union[str, Any]							     =     []

     def __init__(       self  :	Tuple							,				snake_case  :	Optional[int]							,				snake_case  :	str							,				snake_case  :	Tuple							,				snake_case  :	int=None    )		->							List[str]:
          __UpperCAmelCase			:				int													=    obj
          __UpperCAmelCase			:				int													=    target
          __UpperCAmelCase			:				List[str]													=    new
          __UpperCAmelCase			:				Optional[int]													=    target.split('''.'''    )[0]
          __UpperCAmelCase			:				Any													=    {}
          __UpperCAmelCase			:				Any													=    attrs or []

     def __enter__(       self  :	str    )		->							Optional[int]:
          *__UpperCAmelCase							,     __UpperCAmelCase			:				Optional[int]													=    self.target.split('''.'''    )

          # Patch modules:
          # it's used to patch attributes of submodules like "os.path.join";
          # in this case we need to patch "os" and "os.path"

          for i in range(len(snake_case    )    ):
               try:
                    __UpperCAmelCase			:				List[Any]													=    import_module('''.'''.join(submodules[: i + 1]    )    )
               except ModuleNotFoundError:
                    continue
               # We iterate over all the globals in self.obj in case we find "os" or "os.path"
               for attr in self.obj.__dir__():
                    __UpperCAmelCase			:				List[Any]													=    getattr(self.obj							,				snake_case    )
                    # We don't check for the name of the global, but rather if its value *is* "os" or "os.path".
                    # This allows to patch renamed modules like "from os import path as ospath".
                    if obj_attr is submodule or (
                        (isinstance(snake_case							,				_PatchedModuleObj    ) and obj_attr._original_module is submodule)
                    ):
                         __UpperCAmelCase			:				Any													=    obj_attr
                         # patch at top level
                         setattr(self.obj							,				snake_case							,				_PatchedModuleObj(snake_case							,				attrs=self.attrs    )    )
                         __UpperCAmelCase			:				int													=    getattr(self.obj							,				snake_case    )
                         # construct lower levels patches
                         for key in submodules[i + 1 :]:
                              setattr(snake_case							,				snake_case							,				_PatchedModuleObj(getattr(snake_case							,				snake_case							,				snake_case    )							,				attrs=self.attrs    )    )
                              __UpperCAmelCase			:				int													=    getattr(snake_case							,				snake_case    )
                         # finally set the target attribute
                         setattr(snake_case							,				snake_case							,				self.new    )

        # Patch attribute itself:
        # it's used for builtins like "open",
        # and also to patch "os.path.join" we may also need to patch "join"
        # itself if it was imported as "from os.path import join".

          if submodules:  # if it's an attribute of a submodule like "os.path.join"
               try:
                    __UpperCAmelCase			:				Dict													=    getattr(import_module('''.'''.join(snake_case    )    )							,				snake_case    )
               except (AttributeError, ModuleNotFoundError):
                    return
               # We iterate over all the globals in self.obj in case we find "os.path.join"
               for attr in self.obj.__dir__():
                    # We don't check for the name of the global, but rather if its value *is* "os.path.join".
                    # This allows to patch renamed attributes like "from os.path import join as pjoin".
                    if getattr(self.obj							,				snake_case    ) is attr_value:
                         __UpperCAmelCase			:				int													=    getattr(self.obj							,				snake_case    )
                         setattr(self.obj							,				snake_case							,				self.new    )
          elif target_attr in globals()["__builtins__"]:  # if it'a s builtin like "open"
               __UpperCAmelCase			:				int													=    globals()['''__builtins__'''][target_attr]
               setattr(self.obj							,				snake_case							,				self.new    )
          else:
               raise RuntimeError(f'Tried to patch attribute {target_attr} instead of a submodule.'    )

     def __exit__(       self  :	str							,				*snake_case  :	Union[str, Any]    )		->							List[str]:
          for attr in list(self.original    ):
               setattr(self.obj							,				snake_case							,				self.original.pop(snake_case    )    )

     def 				lowerCamelCase__				(       self  :	Optional[Any]    )		->							str:
          self.__enter__()
          self._active_patches.append(self    )






     def 				lowerCamelCase__				(       self  :	str    )		->							Tuple:
          try:
               self._active_patches.remove(self    )
          except ValueError:
               # If the patch hasn't been started this will fail
               return None

          return self.__exit__()



'''simple docstring'''



from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt




def 			_a			(		_lowercase      :			int						):





     '''simple docstring'''






     __UpperCAmelCase			:				int													=    int(number**0.5						)
     return number == sq * sq




def 			_a			(		_lowercase      :			int    ,      _lowercase      :			int    ,      _lowercase      :			int    ,      _lowercase      :			int    ,      _lowercase      :			int    ,      _lowercase      :			int						):





     '''simple docstring'''






     __UpperCAmelCase			:				int													=    x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
     __UpperCAmelCase			:				int													=    x_den * y_den * z_den
     __UpperCAmelCase			:				int													=    gcd(_lowercase    ,      _lowercase						)
     top //= hcf
     bottom //= hcf
     return top, bottom




def 			_a			(		_lowercase      :			int = 35						):





     '''simple docstring'''






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

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

                    # n=-1
                         __UpperCAmelCase			:				Union[str, Any]													=    x_num * y_num
                         __UpperCAmelCase			:				List[Any]													=    x_den * y_num + x_num * y_den
                         __UpperCAmelCase			:				Any													=    gcd(_lowercase    ,      _lowercase						)
                         z_num //= hcf
                         z_den //= hcf
                         if 0 < z_num < z_den <= order:
                              __UpperCAmelCase			:				Optional[Any]													=    add_three(
                                  _lowercase    ,      _lowercase    ,      _lowercase    ,      _lowercase    ,      _lowercase    ,      _lowercase						)
                              unique_s.add(_lowercase						)

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