Do not get perplexed with the name of problem, it has nothing to do with integral calculus. We will concentrate on integration of simple algebraic expressions.
Complex algebraic expressions consisting of integers, addition and multiplication operators and parentheses can be represented by the following BNF notations
< expr > < expr > < term > < term >
< f actor >
< f actor >
→

2/2 a=2+3 a=2+3 b=a∗4 b=a∗4 c=2+3 d=a∗5 d=c∗5 e=b+d e=b+d f=e+6 f=e+6 In both cases, f denotes the original expression (2+3)∗4+(2+3)∗5+6. Here, you have to integrate a sequence of simple expressions into the original one. A simple expression will always be of the form variable = (variable|integer)(+|∗)(variable|integer) For a given sequence of simple expressions, there can be several original expressions. Consider the following cases a = 2 + 3 b = (2 + 3) ∗ 4 b = a ∗ 4 b = ((2 + 3) ∗ 4) Thenbcanbe- b=((2)+(3))∗4 etc. We need the first one, i.e. expression having minimum number of literals. Input The input file will start with an integer, T (1 ≤ T ≤ 100) denoting the number of tests. Each input will start with a positive integer, N (1 ≤ N ≤ 50) which is the number of simple expressions. Subsequent lines will contain the simple expressions defined above. The input will be valid, i.e. it will be always possible to construct a correct expression. Also, variable names will be referenced once they have been assigned. Either variable name or integers can have at most 10 characters. The integers will be always positive here (no unary minus) and variable names will contain letters only. Spaces will be used to separate numbers, variables and operators. Output For each input, print ‘Expression #D:’ followed by the expression denoted by the last variable in the list of simple expressions. Here D is the test number, starting from 1. The length of any expression will not be greater than 5000. Sample Input 2 2 A=2+3 B=A+A 3 A=2+3 B=A+4 C=B+5 Sample Output Expression #1: 2+3+(2+3) Expression #2: 2+3+4+5