'''simple docstring'''




from __future__ import annotations

from collections.abc import MutableSequence




class    a__				:






					def __init__(			self		:		int  ,    a		:		int  ,    a		:		MutableSequence[float]   ):





									"""simple docstring"""



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

									__lowerCamelCase          =  list(_lowerCamelCase   )
									__lowerCamelCase          =  degree






					def __add__(			self		:		List[str]  ,    a		:		Polynomial   ):





									"""simple docstring"""



									if self.degree > polynomial_a.degree:
													__lowerCamelCase          =  self.coefficients[:]
													for i in range(polynomial_a.degree + 1   ):
																	coefficients[i] += polynomial_a.coefficients[i]
													return Polynomial(self.degree  ,    _lowerCamelCase   )
									else:
													__lowerCamelCase          =  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  ,    a		:		Polynomial   ):





									"""simple docstring"""



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






					def __neg__(			self		:		Any   ):





									"""simple docstring"""



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






					def __mul__(			self		:		Optional[int]  ,    a		:		Polynomial   ):





									"""simple docstring"""



									__lowerCamelCase          =  [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        SCREAMING_SNAKE_CASE__       (			self		:		str  ,    a		:		int | float   ):





									"""simple docstring"""



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






					def __str__(			self		:		Optional[Any]   ):





									"""simple docstring"""



									__lowerCamelCase          =  ''''''
									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		:		Any   ):





									"""simple docstring"""



									return self.__str__()






					def        SCREAMING_SNAKE_CASE__       (			self		:		Dict   ):





									"""simple docstring"""



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






					def        SCREAMING_SNAKE_CASE__       (			self		:		Union[str, Any]  ,    a		:		int | float = 0   ):





									"""simple docstring"""



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






					def __eq__(			self		:		List[Any]  ,    a		:		object   ):





									"""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		:		Dict  ,    a		:		object   ):





									"""simple docstring"""



									return not self.__eq__(_lowerCamelCase   )

'''simple docstring'''




def __lowerCAmelCase			(							UpperCamelCase__    )     ->   str:
    __lowerCamelCase          =  []
    __lowerCamelCase          =  set({'''(''', '''[''', '''{'''}    )
    __lowerCamelCase          =  set({''')''', ''']''', '''}'''}    )
    __lowerCamelCase          =  {'''{''': '''}''', '''[''': ''']''', '''(''': ''')'''}

    for i in range(len(UpperCamelCase__    )    ):
        if s[i] in open_brackets:
            stack.append(s[i]    )

        elif s[i] in closed_brackets and (
            len(UpperCamelCase__    ) == 0 or (len(UpperCamelCase__    ) > 0 and open_to_closed[stack.pop()] != s[i])
        ):
            return False

    return len(UpperCamelCase__    ) == 0






def __lowerCAmelCase			(							)     ->   Union[str, Any]:
    __lowerCamelCase          =  input('''Enter sequence of brackets: '''    )
    if is_balanced(UpperCamelCase__    ):
        print(UpperCamelCase__    ,  '''is balanced'''    )
    else:
        print(UpperCamelCase__    ,  '''is not balanced'''    )


if __name__ == "__main__":
  main()
