




from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt







def SCREAMING_SNAKE_CASE    (	lowercase_						)       ->	bool:



       """simple docstring"""

       A__							=   int(number**0.5						)
       return number == sq * sq







def SCREAMING_SNAKE_CASE    (	lowercase_			,    lowercase_			,    lowercase_			,    lowercase_			,    lowercase_			,    lowercase_						)       ->	tuple[int, int]:



       """simple docstring"""

       A__							=   x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
       A__							=   x_den * y_den * z_den
       A__							=   gcd(lowercase_			,    lowercase_						)
       top //= hcf
       bottom //= hcf
       return top, bottom







def SCREAMING_SNAKE_CASE    (	lowercase_ = 35						)       ->	int:



       """simple docstring"""

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

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

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

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








import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
  import torch

  from transformers.generation import DisjunctiveConstraint


@require_torch
class     UpperCamelCase_   (			unittest.TestCase					):

    '''simple docstring'''






    def 	SCREAMING_SNAKE_CASE							(      self				:     Dict)						->Tuple:





           '''simple docstring'''

           A__							=   [[1, 2, 4], [1, 2, 3, 4]]
           A__							=   DisjunctiveConstraint(UpperCAmelCase__)
           self.assertTrue(isinstance(dc.token_ids ,			UpperCAmelCase__))

           with self.assertRaises(UpperCAmelCase__):
                  DisjunctiveConstraint(torch.LongTensor([[1, 2, 4], [1, 2, 3]]))

           with self.assertRaises(UpperCAmelCase__):
                  DisjunctiveConstraint([torch.LongTensor([1, 2, 4]), torch.LongTensor([1, 2, 3, 4, 5])])


    def 	SCREAMING_SNAKE_CASE							(      self				:     int)						->str:





           '''simple docstring'''

           A__							=   [[1, 2], [1, 2, 3, 4]]

           with self.assertRaises(UpperCAmelCase__):
                  DisjunctiveConstraint(UpperCAmelCase__)  # fails here


    def 	SCREAMING_SNAKE_CASE							(      self				:     Any)						->str:





           '''simple docstring'''

           A__							=   [[1, 2, 3], [1, 2, 4]]

           A__							=   DisjunctiveConstraint(UpperCAmelCase__)

           A__			,							A__			,							A__							=   dc.update(1)
           A__							=   stepped is True and completed is False and reset is False
           self.assertTrue(UpperCAmelCase__)
           self.assertTrue(not dc.completed)
           self.assertTrue(dc.current_seq == [1])

           A__			,							A__			,							A__							=   dc.update(2)
           A__							=   stepped is True and completed is False and reset is False
           self.assertTrue(UpperCAmelCase__)
           self.assertTrue(not dc.completed)
           self.assertTrue(dc.current_seq == [1, 2])

           A__			,							A__			,							A__							=   dc.update(3)
           A__							=   stepped is True and completed is True and reset is False
           self.assertTrue(UpperCAmelCase__)
           self.assertTrue(dc.completed)  # Completed!
           self.assertTrue(dc.current_seq == [1, 2, 3])





    def 	SCREAMING_SNAKE_CASE							(      self				:     Optional[Any])						->Tuple:





           '''simple docstring'''

           A__							=   [[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

           A__							=   DisjunctiveConstraint(UpperCAmelCase__)

           A__			,							A__			,							A__							=   dc.update(1)
           self.assertTrue(not dc.completed)
           self.assertTrue(dc.current_seq == [1])

           A__			,							A__			,							A__							=   dc.update(2)
           self.assertTrue(not dc.completed)
           self.assertTrue(dc.current_seq == [1, 2])

           A__			,							A__			,							A__							=   dc.update(4)
           self.assertTrue(not dc.completed)
           self.assertTrue(dc.current_seq == [1, 2, 4])

           A__			,							A__			,							A__							=   dc.update(5)
           self.assertTrue(dc.completed)  # Completed!
           self.assertTrue(dc.current_seq == [1, 2, 4, 5])

           dc.reset()

           A__			,							A__			,							A__							=   dc.update(1)
           self.assertTrue(not dc.completed)
           self.assertTrue(dc.remaining() == 3)
           self.assertTrue(dc.current_seq == [1])

           A__			,							A__			,							A__							=   dc.update(2)
           self.assertTrue(not dc.completed)
           self.assertTrue(dc.remaining() == 2)
           self.assertTrue(dc.current_seq == [1, 2])

           A__			,							A__			,							A__							=   dc.update(5)
           self.assertTrue(dc.completed)  # Completed!
           self.assertTrue(dc.remaining() == 0)
           self.assertTrue(dc.current_seq == [1, 2, 5])


