
'''simple docstring'''
def 							A_  (    __SCREAMING_SNAKE_CASE    :	Optional[Any]      ,  __SCREAMING_SNAKE_CASE    :	Dict			)					->							Any:





  """simple docstring"""

  if not isinstance(_UpperCAmelCase      ,  _UpperCAmelCase			):
    raise TypeError("""plaintext must be a string"""			)
  if not isinstance(_UpperCAmelCase      ,  _UpperCAmelCase			):
    raise TypeError("""key must be a string"""			)

  if not plaintext:
    raise ValueError("""plaintext is empty"""			)
  if not key:
    raise ValueError("""key is empty"""			)

  key += plaintext
  __A		:  Any       				=		plaintext.lower()
  __A		:  Dict       				=		key.lower()
  __A		:  Optional[int]       				=		0
  __A		:  Any       				=		0
  __A		:  Optional[Any]       				=		""""""
  while plaintext_iterator < len(_UpperCAmelCase			):
    if (
        ord(plaintext[plaintext_iterator]			) < 97
        or ord(plaintext[plaintext_iterator]			) > 122
    ):
      ciphertext += plaintext[plaintext_iterator]
      plaintext_iterator += 1
    elif ord(key[key_iterator]			) < 97 or ord(key[key_iterator]			) > 122:
      key_iterator += 1
    else:
      ciphertext += chr(
          (
              (ord(plaintext[plaintext_iterator]			) - 97 + ord(key[key_iterator]			))
              - 97
          )
          % 26
          + 97			)
      key_iterator += 1
      plaintext_iterator += 1
  return ciphertext







def 							A_  (    __SCREAMING_SNAKE_CASE    :	int      ,  __SCREAMING_SNAKE_CASE    :	str			)					->							Union[str, Any]:





  """simple docstring"""

  if not isinstance(_UpperCAmelCase      ,  _UpperCAmelCase			):
    raise TypeError("""ciphertext must be a string"""			)
  if not isinstance(_UpperCAmelCase      ,  _UpperCAmelCase			):
    raise TypeError("""key must be a string"""			)

  if not ciphertext:
    raise ValueError("""ciphertext is empty"""			)
  if not key:
    raise ValueError("""key is empty"""			)

  __A		:  Dict       				=		key.lower()
  __A		:  List[str]       				=		0
  __A		:  List[Any]       				=		0
  __A		:  str       				=		""""""
  while ciphertext_iterator < len(_UpperCAmelCase			):
    if (
        ord(ciphertext[ciphertext_iterator]			) < 97
        or ord(ciphertext[ciphertext_iterator]			) > 122
    ):
      plaintext += ciphertext[ciphertext_iterator]
    else:
      plaintext += chr(
          (ord(ciphertext[ciphertext_iterator]			) - ord(key[key_iterator]			)) % 26
          + 97			)
      key += chr(
          (ord(ciphertext[ciphertext_iterator]			) - ord(key[key_iterator]			)) % 26
          + 97			)
      key_iterator += 1
    ciphertext_iterator += 1
  return plaintext


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     A__ :		List[Any]					=int(input('Type 1 to encrypt or 2 to decrypt:'))
     if operation == 1:
          A__ :		str					=input('Typeplaintext to be encrypted:\n')
          A__ :		List[str]					=input('Type the key:\n')
          print(encrypt(plaintext, key))
     elif operation == 2:
          A__ :		Optional[int]					=input('Type the ciphertext to be decrypted:\n')
          A__ :		Dict					=input('Type the key:\n')
          print(decrypt(ciphertext, key))
     decrypt('jsqqs avvwo', 'coffee')








from __future__ import annotations





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase				):
					"""simple docstring"""






					assert (
					    c % greatest_common_divisor(_UpperCAmelCase       ,			_UpperCAmelCase				) == 0
					)  # greatest_common_divisor(a,b) function implemented below
					((lowercase)   ,      (lowercase)   ,      (lowercase))						   =       extended_gcd(_UpperCAmelCase       ,			_UpperCAmelCase				)  # extended_gcd(a,b) function implemented below
					lowercase						   =       c / d
					return (r * x, r * y)





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase = 2				):
					"""simple docstring"""






					((lowercase)   ,      (lowercase))						   =       diophantine(_UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase				)  # Initial value
					lowercase						   =       greatest_common_divisor(_UpperCAmelCase       ,			_UpperCAmelCase				)
					lowercase						   =       a // d
					lowercase						   =       b // d

					for i in range(_UpperCAmelCase				):
										lowercase						   =       xa + i * q
										lowercase						   =       ya - i * p
										print(_UpperCAmelCase       ,			_UpperCAmelCase				)





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase				):
					"""simple docstring"""






					if a < b:
										lowercase   ,      lowercase						   =       b, a

					while a % b != 0:
										lowercase   ,      lowercase						   =       b, a % b

					return b





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase				):
					"""simple docstring"""






					assert a >= 0 and b >= 0

					if b == 0:
										lowercase   ,      lowercase   ,      lowercase						   =       a, 1, 0
					else:
										((lowercase)   ,      (lowercase)   ,      (lowercase))						   =       extended_gcd(_UpperCAmelCase       ,			a % b				)
										lowercase						   =       q
										lowercase						   =       p - q * (a // b)

					assert a % d == 0 and b % d == 0
					assert d == a * x + b * y

					return (d, x, y)


if __name__ == "__main__":
		from doctest import testmod

		testmod(name='''diophantine''', verbose=True)
		testmod(name='''diophantine_all_soln''', verbose=True)
		testmod(name='''extended_gcd''', verbose=True)
		testmod(name='''greatest_common_divisor''', verbose=True)






