Given A,B, output A+B.
There are multiple testcases in this problem.
Each testcase is preceded by a line containing a integer n (1 <= n <= 5) indicating how many functions in the case.
Following n lines represent the n unary polynomial function in each line.
The syntax of the definition sentance is like the EBNF below:
SENTANCE := NAME=(POLYNOMIAL|COMBINATION)
POLYNOMIAL := TERM[+POLYNOMIAL]
TERM := COEF[(x|x^EXP)]
EXP := digit numbers
COEF := digit numbers
COMBINATION := NAME['](+|-|*)NAME[']
NAME := [A-Z]
I.E. The sentances would be the form "name=definition". The name of the functions are all a single uppercase letter.
And there are two kinds of definition. First kind is simply a describing of polynomial.
The polynomial would be described with this form (-)c1x^e1+(-)c2x^e2+(-).......+(-)cmx^em (ei != ej for i != j). Note that there would be a
constant term without x representing and if the value of exponent is one, the exponent would also not to show. Leading positive sign
would also not appear.
The number of terms of polynomial would not exceed 5 terms. And the absolute value of exponent or coefficient would
not exceed 5.
The second kind of definition is the combination of functions.
The combination is the addition, subtraction or multiplication of other two different functions or their differentiations.
A function name with quotation sign represent the differentiation of the function.
For example:
A=x^2+5+3x
B=Z+D
Z=D'+E
D=E'*W
E=x^3
W=3x
In this case.
D is a multiplication of W and the defferentiation of E, that is (3x^2)*3x = 9x^3
Z is (9x^3)'+(x^3) = x^3+27x^2
B is (x^3+27x^2)+(9x^3) = 10x^3+27x^2
so A+B is 10x^3+28x^2+3x+5
For each case output a line describing A+B as the format of input by descreasing order.