시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB0000.000%

문제

Mathematicians, as opposed to computer scientists, write expressions using single lower case letters as variables. Addition is represented by a plus sign and multiplication is represented by placing the variables or expressions adjacent with no symbol in between. Multiplication is done before addition unless the addition is parenthesized.

For this problem, we consider mathematical expressions consisting of only variables, addition, multiplication, and parentheses. (There are no other symbols, like spaces, division, subtraction, or numerals in the input or output.) For example,

a+b+c
xyz
xyz+ab+cd
(a+b)(c+d)e

Your task is to read in a number of expressions in this notation and to rearrange each, using the laws of algebra, into equivalent expressions with no parentheses. For example,

(a+b)(c+d)e

can be re-expressed as

ace+ade+bce+bde

If there are several solutions, any one will do. The order of variables within terms does not matter, nor does the order of terms within the expression. You do not need to collect like terms; indeed, this is impossible as there are to be no numerals in the output.

입력

The first line of input contains an integer $n$. $n$ lines of input follow, each containing a valid expression as described above. No input line exceeds $100$ characters.

출력

Your output should consist of $n$ lines, each giving a parenthesis-free expression equivalent to the corresponding line of input.

예제 입력 1

5
a+b+c
(a+b)(c+d)e
c+cb+a+c
((a+b)+(c+d))e
(a+a)(a+a)

예제 출력 1

a+b+c
ace+ade+bce+bde
c+cb+a+c
ae+be+ce+de
aa+aa+aa+aa