



"""simple docstring"""







def     UpperCamelCase_   (   lowerCAmelCase__				:    str   ,       lowerCAmelCase__				:    int						)						->       str:

  """simple docstring"""




  lowerCAmelCase_       :    Union[str, Any]								=			[[] for _ in range(snake_case_						)]
  lowerCAmelCase_       :    List[str]								=			key - 1

  if key <= 0:
    raise ValueError('Height of grid can\'t be 0 or negative'						)
  if key == 1 or len(snake_case_						) <= key:
    return input_string

  for position, character in enumerate(snake_case_						):
    lowerCAmelCase_       :    List[Any]								=			position % (lowest * 2)  # puts it in bounds
    lowerCAmelCase_       :    Optional[Any]								=			min(snake_case_   ,       lowest * 2 - num						)  # creates zigzag pattern
    temp_grid[num].append(snake_case_						)
  lowerCAmelCase_       :    Tuple								=			[''.join(snake_case_						) for row in temp_grid]
  lowerCAmelCase_       :    List[Any]								=			''.join(snake_case_						)

  return output_string

def     UpperCamelCase_   (   lowerCAmelCase__				:    str   ,       lowerCAmelCase__				:    int						)						->       str:

  """simple docstring"""




  lowerCAmelCase_       :    Optional[Any]								=			[]
  lowerCAmelCase_       :    List[str]								=			key - 1

  if key <= 0:
    raise ValueError('Height of grid can\'t be 0 or negative'						)
  if key == 1:
    return input_string

  lowerCAmelCase_       :    Union[str, Any]								=			[[] for _ in range(snake_case_						)]  # generates template
  for position in range(len(snake_case_						)						):
    lowerCAmelCase_       :    Optional[Any]								=			position % (lowest * 2)  # puts it in bounds
    lowerCAmelCase_       :    int								=			min(snake_case_   ,       lowest * 2 - num						)  # creates zigzag pattern
    temp_grid[num].append('*'						)

  lowerCAmelCase_       :    List[Any]								=			0
  for row in temp_grid:  # fills in the characters
    lowerCAmelCase_       :    int								=			input_string[counter : counter + len(snake_case_						)]
    grid.append(list(snake_case_						)						)
    counter += len(snake_case_						)

  lowerCAmelCase_       :    Optional[Any]								=			''  # reads as zigzag
  for position in range(len(snake_case_						)						):
    lowerCAmelCase_       :    Optional[int]								=			position % (lowest * 2)  # puts it in bounds
    lowerCAmelCase_       :    str								=			min(snake_case_   ,       lowest * 2 - num						)  # creates zigzag pattern
    output_string += grid[num][0]
    grid[num].pop(0						)
  return output_string

def     UpperCamelCase_   (   lowerCAmelCase__				:    str						)						->       dict[int, str]:

  """simple docstring"""




  lowerCAmelCase_       :    List[Any]								=			{}
  for key_guess in range(1   ,       len(snake_case_						)						):  # tries every key
    lowerCAmelCase_       :    Union[str, Any]								=			decrypt(snake_case_   ,       snake_case_						)
  return results


if __name__ == "__main__":
     import doctest

     doctest.testmod()










"""simple docstring"""







from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt

def     UpperCamelCase_   (   lowerCAmelCase__				:    int						)						->       bool:

  """simple docstring"""




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

def     UpperCamelCase_   (   lowerCAmelCase__				:    int   ,       lowerCAmelCase__				:    int   ,       lowerCAmelCase__				:    int   ,       lowerCAmelCase__				:    int   ,       lowerCAmelCase__				:    int   ,       lowerCAmelCase__				:    int						)						->       tuple[int, int]:

  """simple docstring"""




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

def     UpperCamelCase_   (   lowerCAmelCase__				:    int = 35						)						->       int:

  """simple docstring"""




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

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

                    # n=-1
          lowerCAmelCase_       :    Dict								=			x_num * y_num
          lowerCAmelCase_       :    Optional[int]								=			x_den * y_num + x_num * y_den
          lowerCAmelCase_       :    Any								=			gcd(lowerCAmelCase__   ,       lowerCAmelCase__						)
          z_num //= hcf
          z_den //= hcf
          if 0 < z_num < z_den <= order:
            lowerCAmelCase_       :    Tuple								=			add_three(
                lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__						)
            unique_s.add(lowerCAmelCase__						)

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





