



"""simple docstring"""





from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt
def   a__      ( lowerCAmelCase__ ):
      UpperCAmelCase_     					=				int(number**0.5 )
      return number == sq * sq
def   a__      ( lowerCAmelCase__      ,     lowerCAmelCase__      ,     lowerCAmelCase__      ,     lowerCAmelCase__      ,     lowerCAmelCase__      ,     lowerCAmelCase__ ):
      UpperCAmelCase_     					=				x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
      UpperCAmelCase_     					=				x_den * y_den * z_den
      UpperCAmelCase_     					=				gcd(lowerCAmelCase__      ,     lowerCAmelCase__ )
      top //= hcf
      bottom //= hcf
      return top, bottom
def   a__      ( lowerCAmelCase__ = 35 ):
      UpperCAmelCase_     					=				set()
      UpperCAmelCase_     					=				42
      UpperCAmelCase_     					=				Fraction(0 )
      UpperCAmelCase_     					=				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
                              UpperCAmelCase_     					=				x_num * y_den + x_den * y_num
                              UpperCAmelCase_     					=				x_den * y_den
                              UpperCAmelCase_     					=				gcd(lowerCAmelCase__      ,     lowerCAmelCase__ )
                              z_num //= hcf
                              z_den //= hcf
                              if 0 < z_num < z_den <= order:
                                    UpperCAmelCase_     					=				add_three(
                                        lowerCAmelCase__      ,     lowerCAmelCase__      ,     lowerCAmelCase__      ,     lowerCAmelCase__      ,     lowerCAmelCase__      ,     lowerCAmelCase__ )
                                    unique_s.add(lowerCAmelCase__ )

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

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

                              # n=2
                              UpperCAmelCase_     					=				x_num * x_num * y_num * y_num
                              UpperCAmelCase_     					=				(
                                  x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
                              )
                              if is_sq(lowerCAmelCase__ ) and is_sq(lowerCAmelCase__ ):
                                    UpperCAmelCase_     					=				int(sqrt(lowerCAmelCase__ ) )
                                    UpperCAmelCase_     					=				int(sqrt(lowerCAmelCase__ ) )
                                    UpperCAmelCase_     					=				gcd(lowerCAmelCase__      ,     lowerCAmelCase__ )
                                    z_num //= hcf
                                    z_den //= hcf
                                    if 0 < z_num < z_den <= order:
                                          UpperCAmelCase_     					=				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() = }")







from graphs.minimum_spanning_tree_kruskal import kruskal


def 							__lowerCAmelCase     (							)		->				Optional[Any]:
 '''simple docstring'''


 SCREAMING_SNAKE_CASE		    =      9
 SCREAMING_SNAKE_CASE		    =      [
     [0, 1, 4],
     [0, 7, 8],
     [1, 2, 8],
     [7, 8, 7],
     [7, 6, 1],
     [2, 8, 2],
     [8, 6, 6],
     [2, 3, 7],
     [2, 5, 4],
     [6, 5, 2],
     [3, 5, 14],
     [3, 4, 9],
     [5, 4, 10],
     [1, 7, 11],
 ]

 SCREAMING_SNAKE_CASE		    =      kruskal(_UpperCamelCase		,				_UpperCamelCase						)

 SCREAMING_SNAKE_CASE		    =      [
     [7, 6, 1],
     [2, 8, 2],
     [6, 5, 2],
     [0, 1, 4],
     [2, 5, 4],
     [2, 3, 7],
     [0, 7, 8],
     [3, 4, 9],
 ]

 assert sorted(_UpperCamelCase						) == sorted(_UpperCamelCase						)

