

"""simple docstring"""






class     _UpperCAmelCase			:






			class     _UpperCAmelCase			:
						__a :       Union[str, Any]									=							"""_prev""", """_data""", """_next"""
						def __init__(		self      ,		_A      ,		_A      ,		_A     )    ->    List[Any]:






							'''simple docstring'''







							_UpperCAmelCase    :							Tuple									=					link_p
							_UpperCAmelCase    :							List[str]									=					element
							_UpperCAmelCase    :							Union[str, Any]									=					link_n
						def 							__snake_case (		self     )    ->    int:






							'''simple docstring'''







							return (
							    f''' Prev -> {self._prev is not None}, Next -> {self._next is not None}'''
							)
			def __init__(		self     )    ->    Tuple:






				'''simple docstring'''







				_UpperCAmelCase    :							str									=					self._Node(_A      ,		_A      ,		_A     )
				_UpperCAmelCase    :							Tuple									=					self._Node(_A      ,		_A      ,		_A     )
				_UpperCAmelCase    :							Optional[int]									=					self._trailer
				_UpperCAmelCase    :							List[Any]									=					self._header
				_UpperCAmelCase    :							str									=					0
			def __len__(		self     )    ->    int:






				'''simple docstring'''







				return self._size
			def 							__snake_case (		self     )    ->    Dict:






				'''simple docstring'''







				return self.__len__() == 0
			def 							__snake_case (		self      ,		_A      ,		_A      ,		_A     )    ->    int:






				'''simple docstring'''







				_UpperCAmelCase    :							str									=					self._Node(_A      ,		_A      ,		_A     )
				_UpperCAmelCase    :							Tuple									=					new_node
				_UpperCAmelCase    :							Optional[Any]									=					new_node
				self._size += 1
				return self
			def 							__snake_case (		self      ,		_A     )    ->    Optional[int]:






				'''simple docstring'''







				_UpperCAmelCase    :							Union[str, Any]									=					node._prev
				_UpperCAmelCase    :							Dict									=					node._next

				_UpperCAmelCase    :							int									=					successor
				_UpperCAmelCase    :							Tuple									=					predecessor
				self._size -= 1
				_UpperCAmelCase    :							Any									=					node._data
				_UpperCAmelCase    :							int									=					None
				del node
				return temp






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






				'''simple docstring'''







				if self.is_empty():
					raise Exception("""List is empty"""     )
				return self._header._next._data
			def 							__snake_case (		self     )    ->    int:






				'''simple docstring'''







				if self.is_empty():
					raise Exception("""List is empty"""     )
				return self._trailer._prev._data
			def 							__snake_case (		self      ,		_A     )    ->    int:






				'''simple docstring'''







				return self._insert(self._header      ,		_A      ,		self._header._next     )
			def 							__snake_case (		self      ,		_A     )    ->    Dict:






				'''simple docstring'''







				return self._insert(self._trailer._prev      ,		_A      ,		self._trailer     )
			def 							__snake_case (		self     )    ->    List[Any]:






				'''simple docstring'''







				if self.is_empty():
					raise IndexError("""remove_first from empty list"""     )
				return self._delete(self._header._next     )
			def 							__snake_case (		self     )    ->    Optional[int]:






				'''simple docstring'''







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






"""simple docstring"""






def       UpperCamelCase					(			_lowerCAmelCase     :						int,  _lowerCAmelCase     :						int = 1000 )				->			str:
	if (not isinstance(_lowerCAmelCase,  _lowerCAmelCase )) or (digit_position <= 0):
		raise ValueError("""Digit position must be a positive integer""" )
	elif (not isinstance(_lowerCAmelCase,  _lowerCAmelCase )) or (precision < 0):
		raise ValueError("""Precision must be a nonnegative integer""" )

	# compute an approximation of (16 ** (n - 1)) * pi whose fractional part is mostly
	# accurate
	_UpperCAmelCase    :							List[Any]									=					(
	    4 * _subsum(_lowerCAmelCase,  1,  _lowerCAmelCase )
	    - 2 * _subsum(_lowerCAmelCase,  4,  _lowerCAmelCase )
	    - _subsum(_lowerCAmelCase,  5,  _lowerCAmelCase )
	    - _subsum(_lowerCAmelCase,  6,  _lowerCAmelCase )
	)

	# return the first hex digit of the fractional part of the result
	return hex(int((sum_result % 1) * 16 ) )[2:]
def       UpperCamelCase					(			_lowerCAmelCase     :						int,  _lowerCAmelCase     :						int,  _lowerCAmelCase     :						int )				->			float:
	_UpperCAmelCase    :							Optional[int]									=					0.0
	for sum_index in range(digit_pos_to_extract + precision ):
		_UpperCAmelCase    :							Optional[Any]									=					8 * sum_index + denominator_addend
		if sum_index < digit_pos_to_extract:
			# if the exponential term is an integer and we mod it by the denominator
			# before dividing, only the integer part of the sum will change;
			# the fractional part will not
			_UpperCAmelCase    :							Optional[Any]									=					pow(
			    16,  digit_pos_to_extract - 1 - sum_index,  _lowerCAmelCase )
		else:
			_UpperCAmelCase    :							int									=					pow(16,  digit_pos_to_extract - 1 - sum_index )
		total += exponential_term / denominator
	return total


if __name__ == "__main__":
						import doctest

						doctest.testmod()





