




from __future__ import annotations

from typing import Any
class        __snake_case  :



				def __init__(      self      :		Optional[Any]		,	_UpperCAmelCase      :		int = 6      )  ->    None:





								'''simple docstring'''




								_lowerCAmelCase    :    Node | None										=      None
								_lowerCAmelCase    :    Node | None										=      None
								self.create_linked_list(_UpperCAmelCase      )



				def       SCREAMING_SNAKE_CASE       (      self      :		Union[str, Any]		,	_UpperCAmelCase      :		int      )  ->    None:





								'''simple docstring'''




								_lowerCAmelCase    :    str										=      Node()
								_lowerCAmelCase    :    str										=      current_node
								_lowerCAmelCase    :    List[str]										=      current_node
								_lowerCAmelCase    :    Tuple										=      current_node
								for _ in range(1		,	_UpperCAmelCase      ):
												_lowerCAmelCase    :    Optional[Any]										=      Node()
												_lowerCAmelCase    :    Tuple										=      current_node
												_lowerCAmelCase    :    Tuple										=      previous_node
												_lowerCAmelCase    :    List[str]										=      current_node
								_lowerCAmelCase    :    int										=      self.front
								_lowerCAmelCase    :    Union[str, Any]										=      previous_node



				def       SCREAMING_SNAKE_CASE       (      self      :		int      )  ->    bool:





								'''simple docstring'''




								return (
								    self.front == self.rear
								    and self.front is not None
								    and self.front.data is None
								)



				def       SCREAMING_SNAKE_CASE       (      self      :		Any      )  ->    Any | None:





								'''simple docstring'''




								self.check_can_perform_operation()
								return self.front.data if self.front else None



				def       SCREAMING_SNAKE_CASE       (      self      :		Optional[Any]		,	_UpperCAmelCase      :		Any      )  ->    None:





								'''simple docstring'''




								if self.rear is None:
												return

								self.check_is_full()
								if not self.is_empty():
												_lowerCAmelCase    :    int										=      self.rear.next
								if self.rear:
												_lowerCAmelCase    :    Any										=      data



				def       SCREAMING_SNAKE_CASE       (      self      :		Dict      )  ->    Any:





								'''simple docstring'''




								self.check_can_perform_operation()
								if self.rear is None or self.front is None:
												return None
								if self.front == self.rear:
												_lowerCAmelCase    :    Optional[int]										=      self.front.data
												_lowerCAmelCase    :    Optional[Any]										=      None
												return data

								_lowerCAmelCase    :    Any										=      self.front
								_lowerCAmelCase    :    Optional[Any]										=      old_front.next
								_lowerCAmelCase    :    Optional[int]										=      old_front.data
								_lowerCAmelCase    :    Optional[int]										=      None
								return data



				def       SCREAMING_SNAKE_CASE       (      self      :		int      )  ->    None:





								'''simple docstring'''




								if self.is_empty():
												raise Exception("""Empty Queue"""      )



				def       SCREAMING_SNAKE_CASE       (      self      :		Optional[int]      )  ->    None:





								'''simple docstring'''




								if self.rear and self.rear.next == self.front:
												raise Exception("""Full Queue"""      )






class        __snake_case  :



				def __init__(      self      :		List[str]      )  ->    None:





								'''simple docstring'''




								_lowerCAmelCase    :    Any | None										=      None
								_lowerCAmelCase    :    Node | None										=      None
								_lowerCAmelCase    :    Node | None										=      None


if __name__ == "__main__":
	import doctest

	doctest.testmod()







from __future__ import annotations
class        __snake_case  :



				def __init__(      self      :		Union[str, Any]		,	_UpperCAmelCase      :		int = 0      )  ->    Optional[int]:





								'''simple docstring'''




								_lowerCAmelCase    :    int										=      key



				def       SCREAMING_SNAKE_CASE       (      self      :		Dict		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		int      )  ->    list[str]:





								'''simple docstring'''




								assert isinstance(_UpperCAmelCase		,	_UpperCAmelCase      ) and isinstance(_UpperCAmelCase		,	_UpperCAmelCase      )

								_lowerCAmelCase    :    Optional[Any]										=      key or self.__key or 1

								# make sure key is an appropriate size
								key %= 255

								return [chr(ord(_UpperCAmelCase      ) ^ key      ) for ch in content]



				def       SCREAMING_SNAKE_CASE       (      self      :		List[str]		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		int      )  ->    list[str]:





								'''simple docstring'''




								assert isinstance(_UpperCAmelCase		,	_UpperCAmelCase      ) and isinstance(_UpperCAmelCase		,	_UpperCAmelCase      )

								_lowerCAmelCase    :    List[Any]										=      key or self.__key or 1

								# make sure key is an appropriate size
								key %= 255

								return [chr(ord(_UpperCAmelCase      ) ^ key      ) for ch in content]



				def       SCREAMING_SNAKE_CASE       (      self      :		Optional[Any]		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		int = 0      )  ->    str:





								'''simple docstring'''




								assert isinstance(_UpperCAmelCase		,	_UpperCAmelCase      ) and isinstance(_UpperCAmelCase		,	_UpperCAmelCase      )

								_lowerCAmelCase    :    Union[str, Any]										=      key or self.__key or 1

								# make sure key can be any size
								while key > 255:
												key -= 255

								# This will be returned
								_lowerCAmelCase    :    List[str]										=      """"""

								for ch in content:
												ans += chr(ord(_UpperCAmelCase      ) ^ key      )

								return ans



				def       SCREAMING_SNAKE_CASE       (      self      :		Tuple		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		int = 0      )  ->    str:





								'''simple docstring'''




								assert isinstance(_UpperCAmelCase		,	_UpperCAmelCase      ) and isinstance(_UpperCAmelCase		,	_UpperCAmelCase      )

								_lowerCAmelCase    :    Any										=      key or self.__key or 1

								# make sure key can be any size
								while key > 255:
												key -= 255

								# This will be returned
								_lowerCAmelCase    :    List[Any]										=      """"""

								for ch in content:
												ans += chr(ord(_UpperCAmelCase      ) ^ key      )

								return ans



				def       SCREAMING_SNAKE_CASE       (      self      :		List[str]		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		int = 0      )  ->    bool:





								'''simple docstring'''




								assert isinstance(_UpperCAmelCase		,	_UpperCAmelCase      ) and isinstance(_UpperCAmelCase		,	_UpperCAmelCase      )

								try:
												with open(_UpperCAmelCase      ) as fin, open("""encrypt.out"""		,	"""w+"""      ) as fout:
																# actual encrypt-process
																for line in fin:
																				fout.write(self.encrypt_string(_UpperCAmelCase		,	_UpperCAmelCase      )      )

								except OSError:
												return False

								return True



				def       SCREAMING_SNAKE_CASE       (      self      :		Any		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		int      )  ->    bool:





								'''simple docstring'''




								assert isinstance(_UpperCAmelCase		,	_UpperCAmelCase      ) and isinstance(_UpperCAmelCase		,	_UpperCAmelCase      )

								try:
												with open(_UpperCAmelCase      ) as fin, open("""decrypt.out"""		,	"""w+"""      ) as fout:
																# actual encrypt-process
																for line in fin:
																				fout.write(self.decrypt_string(_UpperCAmelCase		,	_UpperCAmelCase      )      )

								except OSError:
												return False

								return True


# Tests
# crypt = XORCipher()
# key = 67

# # test encrypt
# print(crypt.encrypt("hallo welt",key))
# # test decrypt
# print(crypt.decrypt(crypt.encrypt("hallo welt",key), key))

# # test encrypt_string
# print(crypt.encrypt_string("hallo welt",key))

# # test decrypt_string
# print(crypt.decrypt_string(crypt.encrypt_string("hallo welt",key),key))

# if (crypt.encrypt_file("test.txt",key)):
#       print("encrypt successful")
# else:
#       print("encrypt unsuccessful")

# if (crypt.decrypt_file("encrypt.out",key)):
#       print("decrypt successful")
# else:
#       print("decrypt unsuccessful")

