




"""simple docstring"""

from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt






def 						_snake_case					( _snake_case							: int							)   -> bool:






      '''simple docstring'''


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






def 						_snake_case					( _snake_case							: int    ,  _snake_case							: int    ,  _snake_case							: int    ,  _snake_case							: int    ,  _snake_case							: int    ,  _snake_case							: int							)   -> 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(_snake_case    ,  _snake_case							)
      top //= hcf
      bottom //= hcf
      return top, bottom






def 						_snake_case					( _snake_case							: int = 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(_snake_case    ,  _snake_case							)
                              z_num //= hcf
                              z_den //= hcf
                              if 0 < z_num < z_den <= order:
                                    _A        =       add_three(
                                        _snake_case    ,  _snake_case    ,  _snake_case    ,  _snake_case    ,  _snake_case    ,  _snake_case							)
                                    unique_s.add(_snake_case							)

                              # 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(_snake_case							) and is_sq(_snake_case							):
                                    _A        =       int(sqrt(_snake_case							)							)
                                    _A        =       int(sqrt(_snake_case							)							)
                                    _A        =       gcd(_snake_case    ,  _snake_case							)
                                    z_num //= hcf
                                    z_den //= hcf
                                    if 0 < z_num < z_den <= order:
                                          _A        =       add_three(
                                              _snake_case    ,  _snake_case    ,  _snake_case    ,  _snake_case    ,  _snake_case    ,  _snake_case							)
                                          unique_s.add(_snake_case							)

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

                              # 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(_snake_case							) and is_sq(_snake_case							):
                                    _A        =       int(sqrt(_snake_case							)							)
                                    _A        =       int(sqrt(_snake_case							)							)
                                    _A        =       gcd(_snake_case    ,  _snake_case							)
                                    z_num //= hcf
                                    z_den //= hcf
                                    if 0 < z_num < z_den <= order:
                                          _A        =       add_three(
                                              _snake_case    ,  _snake_case    ,  _snake_case    ,  _snake_case    ,  _snake_case    ,  _snake_case							)
                                          unique_s.add(_snake_case							)

      for num, den in unique_s:
            total += Fraction(_snake_case    ,  _snake_case							)

      return total.denominator + total.numerator


if __name__ == "__main__":
       print(F'''{solution() = }''')







"""simple docstring"""

def 						_snake_case					( _snake_case							: str							)   -> str:






      '''simple docstring'''


      _A        =       ''
      for ch in key:
            if ch == " " or ch not in key_no_dups and ch.isalpha():
                  key_no_dups += ch
      return key_no_dups






def 						_snake_case					( _snake_case							: str							)   -> dict[str, str]:






      '''simple docstring'''


      _A        =       [chr(i + 65							) for i in range(26							)]
      # Remove duplicate characters from key
      _A        =       remove_duplicates(key.upper()							)
      _A        =       len(_snake_case							)
      # First fill cipher with key characters
      _A        =       {alphabet[i]: char for i, char in enumerate(_snake_case							)}
      # Then map remaining characters in alphabet to
      # the alphabet from the beginning
      for i in range(len(_snake_case							)    ,  26							):
            _A        =       alphabet[i - offset]
            # Ensure we are not mapping letters to letters previously mapped
            while char in key:
                  offset -= 1
                  _A        =       alphabet[i - offset]
            _A        =       char
      return cipher_alphabet






def 						_snake_case					( _snake_case							: str    ,  _snake_case							: dict[str, str]							)   -> str:






      '''simple docstring'''


      return "".join(cipher_map.get(_snake_case    ,  _snake_case							) for ch in message.upper()							)






def 						_snake_case					( _snake_case							: str    ,  _snake_case							: dict[str, str]							)   -> str:






      '''simple docstring'''


      _A        =       {v: k for k, v in cipher_map.items()}
      return "".join(rev_cipher_map.get(_snake_case    ,  _snake_case							) for ch in message.upper()							)






def 						_snake_case					( )   -> None:






      '''simple docstring'''


      _A        =       input('Enter message to encode or decode: '							).strip()
      _A        =       input('Enter keyword: '							).strip()
      _A        =       input('Encipher or decipher? E/D:'							).strip()[0].lower()
      try:
            _A        =       {'e': encipher, 'd': decipher}[option]
      except KeyError:
            raise KeyError('invalid input option'							)
      _A        =       create_cipher_map(_snake_case							)
      print(func(_snake_case    ,  _snake_case							)							)


if __name__ == "__main__":
       import doctest

       doctest.testmod()
       main()

