




class 	__lowerCAmelCase			:
       def __init__(		self		:Optional[Any]       ):







        '''simple docstring'''







        a		       =							{}
        # indexmap keys are an index and it's values are the number at that index
        a		       =							{}
       def    lowerCamelCase__							(		self		:Dict	,   __magic_name__		:Union[str, Any]	,   __magic_name__		:Dict       ):







        '''simple docstring'''







        if isinstance(__A	,   (range, str)       ):
         a		       =							list(__A       )
        elif not isinstance(__A	,   __A       ):
         raise TypeError(
             """binary_search_delete() only accepts either a list, range or str"""       )

        a		       =							0
        a		       =							len(__A       ) - 1

        while low <= high:
         a		       =							(low + high) // 2
         if array[mid] == item:
          array.pop(__A       )
          return array
         elif array[mid] < item:
          a		       =							mid + 1
         else:
          a		       =							mid - 1
        raise ValueError(
            """Either the item is not in the array or the array was unsorted"""       )
       def    lowerCamelCase__							(		self		:str	,   __magic_name__		:Optional[Any]	,   __magic_name__		:Any       ):







        '''simple docstring'''







        if isinstance(__A	,   (range, str)       ):
         a		       =							list(__A       )
        elif not isinstance(__A	,   __A       ):
         raise TypeError(
             """binary_search_insert() only accepts either a list, range or str"""       )

        a		       =							0
        a		       =							len(__A       ) - 1

        while low <= high:
         a		       =							(low + high) // 2
         if array[mid] == index:
          # If the item already exists in the array,
          # insert it after the existing item
          array.insert(mid + 1	,   __A       )
          return array
         elif array[mid] < index:
          a		       =							mid + 1
         else:
          a		       =							mid - 1

        # If the item doesn't exist in the array, insert it at the appropriate position
        array.insert(__A	,   __A       )
        return array
       def    lowerCamelCase__							(		self		:Union[str, Any]	,   __magic_name__		:Union[str, Any]	,   __magic_name__		:Dict       ):







        '''simple docstring'''







        if index in self.indexmap:
         a		       =							self.indexmap[index]
         if len(self.numbermap[n]       ) == 1:
          del self.numbermap[n]
         else:
          a		       =							self.binary_search_delete(self.numbermap[n]	,   __A       )

        # Set new index
        a		       =							number

        # Number not seen before or empty so insert number value
        if number not in self.numbermap:
         a		       =							[index]

        # Here we need to perform a binary search insertion in order to insert
        # The item in the correct place
        else:
         a		       =							self.binary_search_insert(
             self.numbermap[number]	,   __A       )





       def    lowerCamelCase__							(		self		:List[Any]	,   __magic_name__		:List[Any]       ):







        '''simple docstring'''







        return self.numbermap.get(__A	,   [-1]       )[0]


if __name__ == "__main__":
  import doctest

  doctest.testmod()







__UpperCamelCase      : Union[str, Any]					      =   {
    "A": ("ABCDEFGHIJKLM", "NOPQRSTUVWXYZ"),
    "B": ("ABCDEFGHIJKLM", "NOPQRSTUVWXYZ"),
    "C": ("ABCDEFGHIJKLM", "ZNOPQRSTUVWXY"),
    "D": ("ABCDEFGHIJKLM", "ZNOPQRSTUVWXY"),
    "E": ("ABCDEFGHIJKLM", "YZNOPQRSTUVWX"),
    "F": ("ABCDEFGHIJKLM", "YZNOPQRSTUVWX"),
    "G": ("ABCDEFGHIJKLM", "XYZNOPQRSTUVW"),
    "H": ("ABCDEFGHIJKLM", "XYZNOPQRSTUVW"),
    "I": ("ABCDEFGHIJKLM", "WXYZNOPQRSTUV"),
    "J": ("ABCDEFGHIJKLM", "WXYZNOPQRSTUV"),
    "K": ("ABCDEFGHIJKLM", "VWXYZNOPQRSTU"),
    "L": ("ABCDEFGHIJKLM", "VWXYZNOPQRSTU"),
    "M": ("ABCDEFGHIJKLM", "UVWXYZNOPQRST"),
    "N": ("ABCDEFGHIJKLM", "UVWXYZNOPQRST"),
    "O": ("ABCDEFGHIJKLM", "TUVWXYZNOPQRS"),
    "P": ("ABCDEFGHIJKLM", "TUVWXYZNOPQRS"),
    "Q": ("ABCDEFGHIJKLM", "STUVWXYZNOPQR"),
    "R": ("ABCDEFGHIJKLM", "STUVWXYZNOPQR"),
    "S": ("ABCDEFGHIJKLM", "RSTUVWXYZNOPQ"),
    "T": ("ABCDEFGHIJKLM", "RSTUVWXYZNOPQ"),
    "U": ("ABCDEFGHIJKLM", "QRSTUVWXYZNOP"),
    "V": ("ABCDEFGHIJKLM", "QRSTUVWXYZNOP"),
    "W": ("ABCDEFGHIJKLM", "PQRSTUVWXYZNO"),
    "X": ("ABCDEFGHIJKLM", "PQRSTUVWXYZNO"),
    "Y": ("ABCDEFGHIJKLM", "OPQRSTUVWXYZN"),
    "Z": ("ABCDEFGHIJKLM", "OPQRSTUVWXYZN"),
}





def 	__A	(			__lowerCamelCase					)   -> list[tuple[str, str]]:
	return [alphabet[char] for char in key.upper()]





def 	__A	(			__lowerCamelCase							,    __lowerCamelCase					)   -> str:
	a		       =							""""""
	a		       =							0
	a		       =							generate_table(__lowerCamelCase					)
	for char in words.upper():
		cipher += get_opponent(table[count]							,    __lowerCamelCase					)
		a		       =							(count + 1) % len(__lowerCamelCase					)
	return cipher





def 	__A	(			__lowerCamelCase							,    __lowerCamelCase					)   -> str:
	return encrypt(__lowerCamelCase							,    __lowerCamelCase					)





def 	__A	(			__lowerCamelCase							,    __lowerCamelCase					)   -> tuple[int, int]:
	a		       =							0 if char in table[0] else 1
	a		       =							table[row].index(__lowerCamelCase					)
	return row, col





def 	__A	(			__lowerCamelCase							,    __lowerCamelCase					)   -> str:
	a       ,				a		       =							get_position(__lowerCamelCase							,    char.upper()					)
	if row == 1:
		return table[0][col]
	else:
		return table[1][col] if row == 0 else char


if __name__ == "__main__":
		import doctest

		doctest.testmod()  # Fist ensure that all our tests are passing...
		__UpperCamelCase      : int					      =   input("Enter key: ").strip()
		__UpperCamelCase      : int					      =   input("Enter text to encrypt: ").strip()
		__UpperCamelCase      : Optional[Any]					      =   encrypt(key, text)

		print(F'Encrypted: {cipher_text}')
		print(F'Decrypted with key: {decrypt(key, cipher_text)}')

