from string import ascii_uppercase

A_      =      {str(ord(c) - 55): c for c in ascii_uppercase}






def        __UpperCAmelCase    (       UpperCAmelCase,		UpperCAmelCase       )->       Any:



			"""simple docstring"""







			if isinstance(_SCREAMING_SNAKE_CASE,		_SCREAMING_SNAKE_CASE       ):
						raise TypeError('''int() can\'t convert non-string with explicit base'''       )
			if num < 0:
						raise ValueError('''parameter must be positive int'''       )
			if isinstance(_SCREAMING_SNAKE_CASE,		_SCREAMING_SNAKE_CASE       ):
						raise TypeError('''\'str\' object cannot be interpreted as an integer'''       )
			if isinstance(_SCREAMING_SNAKE_CASE,		_SCREAMING_SNAKE_CASE       ):
						raise TypeError('''\'float\' object cannot be interpreted as an integer'''       )
			if base in (0, 1):
						raise ValueError('''base must be >= 2'''       )
			if base > 36:
						raise ValueError('''base must be <= 36'''       )
			lowercase							=		''''''
			lowercase							=		0
			lowercase							=		0
			while div != 1:
						lowercase		,lowercase							=		divmod(_SCREAMING_SNAKE_CASE,		_SCREAMING_SNAKE_CASE       )
						if base >= 11 and 9 < mod < 36:
									lowercase							=		ALPHABET_VALUES[str(_SCREAMING_SNAKE_CASE       )]
						else:
									lowercase							=		str(_SCREAMING_SNAKE_CASE       )
						new_value += actual_value
						lowercase							=		num // base
						lowercase							=		div
						if div == 0:
									return str(new_value[::-1]       )
						elif div == 1:
									new_value += str(_SCREAMING_SNAKE_CASE       )
									return str(new_value[::-1]       )

			return new_value[::-1]


if __name__ == "__main__":
						import doctest

						doctest.testmod()

						for base in range(2, 37):
												for num in range(1000):
																		assert int(decimal_to_any(num, base), base) == num, (
																		    num,
																		    base,
																		    decimal_to_any(num, base),
																		    int(decimal_to_any(num, base), base),
																		)






from __future__ import annotations

from collections.abc import MutableSequence






class      __lowercase					:

						def __init__(	self				:      Optional[Any]							,							__lowerCamelCase				:      int							,							__lowerCamelCase				:      MutableSequence[float]   )							->		None:


									'''simple docstring'''

									if len(__lowerCamelCase   ) != degree + 1:
												raise ValueError(
												    '''The number of coefficients should be equal to the degree + 1.'''   )

									lowercase							=		list(__lowerCamelCase   )
									lowercase							=		degree

						def __add__(	self				:      Any							,							__lowerCamelCase				:      Polynomial   )							->		Polynomial:


									'''simple docstring'''

									if self.degree > polynomial_a.degree:
												lowercase							=		self.coefficients[:]
												for i in range(polynomial_a.degree + 1   ):
															coefficients[i] += polynomial_a.coefficients[i]
												return Polynomial(self.degree							,							__lowerCamelCase   )
									else:
												lowercase							=		polynomial_a.coefficients[:]
												for i in range(self.degree + 1   ):
															coefficients[i] += self.coefficients[i]
												return Polynomial(polynomial_a.degree							,							__lowerCamelCase   )

						def __sub__(	self				:      str							,							__lowerCamelCase				:      Polynomial   )							->		Polynomial:


									'''simple docstring'''

									return self + polynomial_a * Polynomial(0							,							[-1]   )

						def __neg__(	self				:      str   )							->		Polynomial:


									'''simple docstring'''

									return Polynomial(self.degree							,							[-c for c in self.coefficients]   )

						def __mul__(	self				:      List[str]							,							__lowerCamelCase				:      Polynomial   )							->		Polynomial:


									'''simple docstring'''

									lowercase							=		[0] * (self.degree + polynomial_a.degree + 1)
									for i in range(self.degree + 1   ):
												for j in range(polynomial_a.degree + 1   ):
															coefficients[i + j] += (
															    self.coefficients[i] * polynomial_a.coefficients[j]
															)

									return Polynomial(self.degree + polynomial_a.degree							,							__lowerCamelCase   )

						def        __a		(	self				:      List[str]							,							__lowerCamelCase				:      int | float   )							->		int | float:


									'''simple docstring'''

									lowercase							=		0
									for i in range(self.degree + 1   ):
												result += self.coefficients[i] * (substitution**i)
									return result

						def __str__(	self				:      str   )							->		str:


									'''simple docstring'''

									lowercase							=		''''''
									for i in range(self.degree							,							-1							,							-1   ):
												if self.coefficients[i] == 0:
															continue
												elif self.coefficients[i] > 0:
															if polynomial:
																		polynomial += " + "
												else:
															polynomial += " - "

												if i == 0:
															polynomial += str(abs(self.coefficients[i]   )   )
												elif i == 1:
															polynomial += str(abs(self.coefficients[i]   )   ) + "x"
												else:
															polynomial += str(abs(self.coefficients[i]   )   ) + "x^" + str(__lowerCamelCase   )

									return polynomial

						def __repr__(	self				:      Tuple   )							->		str:


									'''simple docstring'''

									return self.__str__()

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


									'''simple docstring'''

									lowercase							=		[0] * self.degree
									for i in range(self.degree   ):
												lowercase							=		self.coefficients[i + 1] * (i + 1)
									return Polynomial(self.degree - 1							,							__lowerCamelCase   )

						def        __a		(	self				:      Union[str, Any]							,							__lowerCamelCase				:      int | float = 0   )							->		Polynomial:


									'''simple docstring'''

									lowercase							=		[0] * (self.degree + 2)
									lowercase							=		constant
									for i in range(self.degree + 1   ):
												lowercase							=		self.coefficients[i] / (i + 1)
									return Polynomial(self.degree + 1							,							__lowerCamelCase   )

						def __eq__(	self				:      Tuple							,							__lowerCamelCase				:      object   )							->		bool:


									'''simple docstring'''

									if not isinstance(__lowerCamelCase							,							__lowerCamelCase   ):
												return False

									if self.degree != polynomial_a.degree:
												return False

									for i in range(self.degree + 1   ):
												if self.coefficients[i] != polynomial_a.coefficients[i]:
															return False

									return True



						def __ne__(	self				:      Tuple							,							__lowerCamelCase				:      object   )							->		bool:


									'''simple docstring'''

									return not self.__eq__(__lowerCamelCase   )





