





from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt



def 		A_				(     _lowerCAmelCase     )						-> bool:
 UpperCamelCase	:					int       	=   int(number**0.5     )
 return number == sq * sq



def 		A_				(     _lowerCAmelCase							,   _lowerCAmelCase							,   _lowerCAmelCase							,   _lowerCAmelCase							,   _lowerCAmelCase							,   _lowerCAmelCase     )						-> tuple[int, int]:
 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(_lowerCAmelCase							,   _lowerCAmelCase     )
 top //= hcf
 bottom //= hcf
 return top, bottom



def 		A_				(     _lowerCAmelCase = 35     )						-> int:
 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	:					Dict       	=   x_num * y_den + x_den * y_num
     UpperCamelCase	:					Any       	=   x_den * y_den
     UpperCamelCase	:					int       	=   gcd(_lowerCAmelCase							,   _lowerCAmelCase     )
     z_num //= hcf
     z_den //= hcf
     if 0 < z_num < z_den <= order:
      UpperCamelCase	:					str       	=   add_three(
          _lowerCAmelCase							,   _lowerCAmelCase							,   _lowerCAmelCase							,   _lowerCAmelCase							,   _lowerCAmelCase							,   _lowerCAmelCase     )
      unique_s.add(_lowerCAmelCase     )

     # n=2
     UpperCamelCase	:					List[Any]       	=   (
         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(_lowerCAmelCase     ) and is_sq(_lowerCAmelCase     ):
      UpperCamelCase	:					Any       	=   int(sqrt(_lowerCAmelCase     )     )
      UpperCamelCase	:					Optional[int]       	=   int(sqrt(_lowerCAmelCase     )     )
      UpperCamelCase	:					str       	=   gcd(_lowerCAmelCase							,   _lowerCAmelCase     )
      z_num //= hcf
      z_den //= hcf
      if 0 < z_num < z_den <= order:
       UpperCamelCase	:					int       	=   add_three(
           _lowerCAmelCase							,   _lowerCAmelCase							,   _lowerCAmelCase							,   _lowerCAmelCase							,   _lowerCAmelCase							,   _lowerCAmelCase     )
       unique_s.add(_lowerCAmelCase     )

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

     # n=2
     UpperCamelCase	:					str       	=   x_num * x_num * y_num * y_num
     UpperCamelCase	:					Tuple       	=   (
         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	:					Optional[Any]       	=   int(sqrt(_lowerCAmelCase     )     )
      UpperCamelCase	:					Tuple       	=   int(sqrt(_lowerCAmelCase     )     )
      UpperCamelCase	:					int       	=   gcd(_lowerCAmelCase							,   _lowerCAmelCase     )
      z_num //= hcf
      z_den //= hcf
      if 0 < z_num < z_den <= order:
       UpperCamelCase	:					List[Any]       	=   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() = }""")







class     SCREAMING_SNAKE_CASE__ :



 def __init__(							self,__lowerCamelCase ):
        A__											=						set_counts
        A__											=						max(__lowerCamelCase )
        A__											=						len(__lowerCamelCase )
        A__											=						[1] * num_sets
        A__											=						list(range(__lowerCamelCase ) )



 def 				UpperCamelCase			(							self,__lowerCamelCase,__lowerCamelCase ):
        A__											=						self.get_parent(__lowerCamelCase )
        A__											=						self.get_parent(__lowerCamelCase )

        if src_parent == dst_parent:
               return False

        if self.ranks[dst_parent] >= self.ranks[src_parent]:
               self.set_counts[dst_parent] += self.set_counts[src_parent]
               A__											=						0
               A__											=						dst_parent
               if self.ranks[dst_parent] == self.ranks[src_parent]:
                      self.ranks[dst_parent] += 1
               A__											=						self.set_counts[dst_parent]
        else:
               self.set_counts[src_parent] += self.set_counts[dst_parent]
               A__											=						0
               A__											=						src_parent
               A__											=						self.set_counts[src_parent]

        A__											=						max(self.max_set,__lowerCamelCase )
        return True




 def 				UpperCamelCase			(							self,__lowerCamelCase ):
        if self.parents[disj_set] == disj_set:
               return disj_set
        A__											=						self.get_parent(self.parents[disj_set] )
        return self.parents[disj_set]





