





'''simple docstring'''



class 							__lowercase				:







	'''simple docstring'''

	class 							__lowercase				:







		'''simple docstring'''

		a			: List[Any]      =				"_prev", "_data", "_next"


		def __init__(self   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase       )							->							Tuple:







					'''simple docstring'''





					__lowercase   =							link_p
					__lowercase   =							element
					__lowercase   =							link_n


		def   _UpperCAmelCase   (self       )							->							Tuple:







					'''simple docstring'''





					return (
					    f" Prev -> {self._prev is not None}, Next -> {self._next is not None}"
					)





	def __init__(self       )							->							Any:







				'''simple docstring'''





				__lowercase   =							self._Node(_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase       )
				__lowercase   =							self._Node(_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase       )
				__lowercase   =							self._trailer
				__lowercase   =							self._header
				__lowercase   =							0


	def __len__(self       )							->							Dict:







				'''simple docstring'''





				return self._size


	def   _UpperCAmelCase   (self       )							->							int:







				'''simple docstring'''





				return self.__len__() == 0


	def   _UpperCAmelCase   (self   ,_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase       )							->							Optional[int]:







				'''simple docstring'''





				__lowercase   =							self._Node(_lowerCamelCase   ,_lowerCamelCase   ,_lowerCamelCase       )
				__lowercase   =							new_node
				__lowercase   =							new_node
				self._size += 1
				return self


	def   _UpperCAmelCase   (self   ,_lowerCamelCase       )							->							str:







				'''simple docstring'''





				__lowercase   =							node._prev
				__lowercase   =							node._next

				__lowercase   =							successor
				__lowercase   =							predecessor
				self._size -= 1
				__lowercase   =							node._data
				__lowercase   =							__lowercase   =							__lowercase   =							None
				del node
				return temp






class 							__lowercase				(					_DoublyLinkedBase  ):







	'''simple docstring'''

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







				'''simple docstring'''





				if self.is_empty():
							raise Exception('''List is empty'''       )
				return self._header._next._data


	def   _UpperCAmelCase   (self       )							->							Optional[int]:







				'''simple docstring'''





				if self.is_empty():
							raise Exception('''List is empty'''       )
				return self._trailer._prev._data


	def   _UpperCAmelCase   (self   ,_lowerCamelCase       )							->							str:







				'''simple docstring'''





				return self._insert(self._header   ,_lowerCamelCase   ,self._header._next       )


	def   _UpperCAmelCase   (self   ,_lowerCamelCase       )							->							Tuple:







				'''simple docstring'''





				return self._insert(self._trailer._prev   ,_lowerCamelCase   ,self._trailer       )


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







				'''simple docstring'''





				if self.is_empty():
							raise IndexError('''remove_first from empty list'''       )
				return self._delete(self._header._next       )


	def   _UpperCAmelCase   (self       )							->							List[str]:







				'''simple docstring'''





				if self.is_empty():
							raise IndexError('''remove_first from empty list'''       )
				return self._delete(self._trailer._prev       )







"""simple docstring"""




# Lint as: python3

import hashlib
from typing import Union

def   UpperCamelCase_  (		SCREAMING_SNAKE_CASE_			):
					if isinstance(SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			):
										# Data already in bytes, returns as it as
										return hash_data
					elif isinstance(SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			):
										# We keep the data as it as for it ot be later encoded to UTF-8
										# However replace `\\` with `/` for Windows compatibility
										SCREAMING_SNAKE_CASE				=	hash_data.replace('\\',     '/'			)
					elif isinstance(SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			):
										SCREAMING_SNAKE_CASE				=	str(SCREAMING_SNAKE_CASE_			)
					else:
										# If data is not of the required type, raise error
										raise InvalidKeyError(SCREAMING_SNAKE_CASE_			)

					return hash_data.encode('utf-8'			)




class      UpperCamelCase	(       __magic_name__      ):

				"""simple docstring"""



				def __init__(				self		,	lowercase__			)    ->    Dict:
									"""simple docstring"""







									SCREAMING_SNAKE_CASE				=	'\nFAILURE TO GENERATE DATASET: Invalid key type detected'
									SCREAMING_SNAKE_CASE				=	f'''\nFound Key {hash_data} of type {type(lowercase__			)}'''
									SCREAMING_SNAKE_CASE				=	'\nKeys should be either str, int or bytes type'
									super().__init__(f'''{self.prefix}{self.err_msg}{self.suffix}'''			)






class      UpperCamelCase	(       __magic_name__      ):

				"""simple docstring"""



				def __init__(				self		,	lowercase__		,	lowercase__		,	lowercase__=""			)    ->    Tuple:
									"""simple docstring"""







									SCREAMING_SNAKE_CASE				=	key
									SCREAMING_SNAKE_CASE				=	duplicate_key_indices
									SCREAMING_SNAKE_CASE				=	fix_msg
									SCREAMING_SNAKE_CASE				=	'Found multiple examples generated with the same key'
									if len(lowercase__			) <= 20:
														SCREAMING_SNAKE_CASE				=	f'''\nThe examples at index {', '.join(lowercase__			)} have the key {key}'''
									else:
														SCREAMING_SNAKE_CASE				=	f'''\nThe examples at index {', '.join(duplicate_key_indices[:20]			)}... ({len(lowercase__			) - 20} more) have the key {key}'''
									SCREAMING_SNAKE_CASE				=	'\n' + fix_msg if fix_msg else ''
									super().__init__(f'''{self.prefix}{self.err_msg}{self.suffix}'''			)






class      UpperCamelCase	:

				"""simple docstring"""



				def __init__(				self		,	lowercase__			)    ->    Union[str, Any]:
									"""simple docstring"""







									SCREAMING_SNAKE_CASE				=	hashlib.mda(_as_bytes(lowercase__			)			)




				def 							A					(				self		,	lowercase__			)    ->    int:
									"""simple docstring"""







									SCREAMING_SNAKE_CASE				=	self._split_mda.copy()
									SCREAMING_SNAKE_CASE				=	_as_bytes(lowercase__			)
									mda.update(lowercase__			)
									# Convert to integer with hexadecimal conversion
									return int(mda.hexdigest()		,	16			)
