
"""simple docstring"""





class A_      :




  '''simple docstring'''







  def __init__(						self							,  lowercase_    ):

     """simple docstring"""
     UpperCAmelCase_   :   str     	=       data
     UpperCAmelCase_   :   str     	=       None
     UpperCAmelCase_   :   List[Any]     	=       None







  def __str__(						self    ):

     """simple docstring"""
     return F"""{self.data}"""




class A_      :




  '''simple docstring'''







  def __init__(						self    ):

     """simple docstring"""
     UpperCAmelCase_   :   Tuple     	=       None
     UpperCAmelCase_   :   List[str]     	=       None







  def __iter__(						self    ):

     """simple docstring"""
     UpperCAmelCase_   :   Optional[int]     	=       self.head
     while node:
        yield node.data
        UpperCAmelCase_   :   Optional[Any]     	=       node.next







  def __str__(						self    ):

     """simple docstring"""
     return "->".join([str(lowercase_    ) for item in self]    )







  def __len__(						self    ):

     """simple docstring"""
     return sum(1 for _ in self    )







  def 			UpperCamelCase__   (						self							,  lowercase_    ):

     """simple docstring"""
     self.insert_at_nth(0							,  lowercase_    )







  def 			UpperCamelCase__   (						self							,  lowercase_    ):

     """simple docstring"""
     self.insert_at_nth(len(self    )							,  lowercase_    )







  def 			UpperCamelCase__   (						self							,  lowercase_							,  lowercase_    ):

     """simple docstring"""
     UpperCAmelCase_   :   int     	=       len(self    )

     if not 0 <= index <= length:
        raise IndexError("list index out of range"    )
     UpperCAmelCase_   :   Tuple     	=       Node(lowercase_    )
     if self.head is None:
        UpperCAmelCase_   :   List[str]     	=       new_node
     elif index == 0:
        UpperCAmelCase_   :   int     	=       new_node
        UpperCAmelCase_   :   Optional[Any]     	=       self.head
        UpperCAmelCase_   :   Optional[int]     	=       new_node
     elif index == length:
        UpperCAmelCase_   :   Union[str, Any]     	=       new_node
        UpperCAmelCase_   :   Optional[Any]     	=       self.tail
        UpperCAmelCase_   :   Tuple     	=       new_node
     else:
        UpperCAmelCase_   :   Dict     	=       self.head
        for _ in range(0							,  lowercase_    ):
           UpperCAmelCase_   :   str     	=       temp.next
        UpperCAmelCase_   :   int     	=       new_node
        UpperCAmelCase_   :   Tuple     	=       temp.previous
        UpperCAmelCase_   :   Union[str, Any]     	=       temp
        UpperCAmelCase_   :   int     	=       new_node







  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     return self.delete_at_nth(0    )







  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     return self.delete_at_nth(len(self    ) - 1    )







  def 			UpperCamelCase__   (						self							,  lowercase_    ):

     """simple docstring"""
     UpperCAmelCase_   :   int     	=       len(self    )

     if not 0 <= index <= length - 1:
        raise IndexError("list index out of range"    )
     UpperCAmelCase_   :   Optional[int]     	=       self.head  # default first node
     if length == 1:
        UpperCAmelCase_   :   Union[str, Any]     	=       None
     elif index == 0:
        UpperCAmelCase_   :   List[Any]     	=       self.head.next
        UpperCAmelCase_   :   str     	=       None
     elif index == length - 1:
        UpperCAmelCase_   :   str     	=       self.tail
        UpperCAmelCase_   :   Optional[Any]     	=       self.tail.previous
        UpperCAmelCase_   :   Any     	=       None
     else:
        UpperCAmelCase_   :   List[Any]     	=       self.head
        for _ in range(0							,  lowercase_    ):
           UpperCAmelCase_   :   str     	=       temp.next
        UpperCAmelCase_   :   Dict     	=       temp
        UpperCAmelCase_   :   Optional[Any]     	=       temp.previous
        UpperCAmelCase_   :   int     	=       temp.next
     return delete_node.data







  def 			UpperCamelCase__   (						self							,  lowercase_    ):

     """simple docstring"""
     UpperCAmelCase_   :   Tuple     	=       self.head

     while current.data != data:  # Find the position to delete
        if current.next:
           UpperCAmelCase_   :   List[str]     	=       current.next
        else:  # We have reached the end an no value matches
           raise ValueError("No data matching given value"    )

     if current == self.head:
        self.delete_head()

     elif current == self.tail:
        self.delete_tail()

     else:  # Before: 1 <--> 2(current) <--> 3
        UpperCAmelCase_   :   str     	=       current.next  # 1 --> 3
        UpperCAmelCase_   :   Optional[Any]     	=       current.previous  # 1 <--> 3
     return data







  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     return len(self    ) == 0







def       __a	(						):
   UpperCAmelCase_   :   Dict     	=       DoublyLinkedList()
   assert linked_list.is_empty() is True
   assert str(__lowerCamelCase    ) == ""

   try:
      linked_list.delete_head()
      raise AssertionError  # This should not happen.
   except IndexError:
      assert True  # This should happen.

   try:
      linked_list.delete_tail()
      raise AssertionError  # This should not happen.
   except IndexError:
      assert True  # This should happen.

   for i in range(10    ):
      assert len(__lowerCamelCase    ) == i
      linked_list.insert_at_nth(__lowerCamelCase,						i + 1    )
   assert str(__lowerCamelCase    ) == "->".join(str(__lowerCamelCase    ) for i in range(1,						11    )    )

   linked_list.insert_at_head(0    )
   linked_list.insert_at_tail(11    )
   assert str(__lowerCamelCase    ) == "->".join(str(__lowerCamelCase    ) for i in range(0,						12    )    )

   assert linked_list.delete_head() == 0
   assert linked_list.delete_at_nth(9    ) == 10
   assert linked_list.delete_tail() == 11
   assert len(__lowerCamelCase    ) == 9
   assert str(__lowerCamelCase    ) == "->".join(str(__lowerCamelCase    ) for i in range(1,						10    )    )


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

    testmod()




"""simple docstring"""





def       __a	(						__lowerCamelCase,						__lowerCamelCase    ):
   if not isinstance(__lowerCamelCase,						__lowerCamelCase    ):
      raise TypeError("plaintext must be a string"    )
   if not isinstance(__lowerCamelCase,						__lowerCamelCase    ):
      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
   UpperCAmelCase_   :   Optional[int]     	=       plaintext.lower()
   UpperCAmelCase_   :   Any     	=       key.lower()
   UpperCAmelCase_   :   Optional[int]     	=       0
   UpperCAmelCase_   :   List[str]     	=       0
   UpperCAmelCase_   :   Optional[int]     	=       ""
   while plaintext_iterator < len(__lowerCamelCase    ):
      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	(						__lowerCamelCase,						__lowerCamelCase    ):
   if not isinstance(__lowerCamelCase,						__lowerCamelCase    ):
      raise TypeError("ciphertext must be a string"    )
   if not isinstance(__lowerCamelCase,						__lowerCamelCase    ):
      raise TypeError("key must be a string"    )

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

   UpperCAmelCase_   :   List[str]     	=       key.lower()
   UpperCAmelCase_   :   Tuple     	=       0
   UpperCAmelCase_   :   Optional[int]     	=       0
   UpperCAmelCase_   :   Dict     	=       ""
   while ciphertext_iterator < len(__lowerCamelCase    ):
      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									=				int(input('Type 1 to encrypt or 2 to decrypt:'))
    if operation == 1:
        _a									=				input('Typeplaintext to be encrypted:\n')
        _a									=				input('Type the key:\n')
        print(encrypt(plaintext, key))
    elif operation == 2:
        _a									=				input('Type the ciphertext to be decrypted:\n')
        _a									=				input('Type the key:\n')
        print(decrypt(ciphertext, key))
    decrypt('jsqqs avvwo', 'coffee')


