

"""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 )				->			str:
	_UpperCAmelCase    :							Any									=					1
	_UpperCAmelCase    :							List[str]									=					0
	_UpperCAmelCase    :							str									=					1
	_UpperCAmelCase    :							Union[str, Any]									=					1
	_UpperCAmelCase    :							int									=					3
	_UpperCAmelCase    :							int									=					3
	_UpperCAmelCase    :							List[str]									=					limit
	_UpperCAmelCase    :							Optional[Any]									=					0

	_UpperCAmelCase    :							Any									=					""""""
	while counter != decimal + 1:
		if 4 * q + r - t < n * t:
			result += str(_lowerCAmelCase )
			if counter == 0:
				result += "."

			if decimal == counter:
				break

			counter += 1
			_UpperCAmelCase    :							str									=					10 * (r - n * t)
			_UpperCAmelCase    :							List[Any]									=					((10 * (3 * q + r)) // t) - 10 * n
			q *= 10
			_UpperCAmelCase    :							int									=					nr
		else:
			_UpperCAmelCase    :							Any									=					(2 * q + r) * l
			_UpperCAmelCase    :							str									=					(q * (7 * k) + 2 + (r * l)) // (t * l)
			q *= k
			t *= l
			l += 2
			k += 1
			_UpperCAmelCase    :							List[Any]									=					nn
			_UpperCAmelCase    :							Optional[int]									=					nr
	return result
def       UpperCamelCase					(			)				->			None:
	print(f'''{calculate_pi(50 ) = }''' )
	import doctest

	doctest.testmod()


if __name__ == "__main__":
						main()





