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

## 문제

We are given an arithmetic expression template w that consists of four basic types of operations, some brackets and holes, denoted by x, that represent some missing numbers. For instance, (x*x)/(x+x) is a valid template.

A valuation of a template consists in inserting real numbers to the template so that the value of the resulting expression is correctly defined. For instance, by inserting the numbers 1, 2, 3, 4 into the respective holes in the example above, we obtain an expression that evaluates to (1×2)/(3+4) = 2/7, whereas inserting the numbers 1, 2, 3, -3 yields an expression with undefined value, hence this is not a valuation.

If the sets of valuations of two templates w and w' are the same and for each valuation the expressions obtained from w and w' have the same value, and the template w' can be obtained by inserting and/or deleting some brackets from the template w, we say that the two templates are equivalent. For instance, the templates (x*x)/(x+x) and x*x/(x+x) are equivalent. On the other hand, the templates (x*x)/(x+x) and x*x/x+x are not equivalent, since the valuation 1, 2, 3, 4 of these templates yields two expressions that are evaluated to 2/7 and 14/3 respectively. Also the templates x-(x-x) and x-x+x are not equivalent since none of them can be transformed to the other by inserting or removing brackets.

Your task is to find a template with the minimum number of brackets among templates equivalent to a given template.

Multiplication and division have the same priority, which is greater than the priority of addition and subtraction. Hence, multiplication and division are performed before addition and subtraction. Addition and subtraction have the same priority. Operations with the same priority are performed from left to right.

## 입력

The first line of input contains an integer n that represents the number of expression templates in the input. Each of the following n lines contains a non-empty, correct expression template consisting of the characters +, -, *, /, (, ) and x (the holes). The sum of lengths of all the expressions does not exceed 106.

## 출력

Your program should output n lines. The i-th line should contain a template that is equivalent to the -th template from the input, which contains the minimum number of brackets.

## 예제 입력 1

2
x+(x+(x+x)-(x*x))/x
(x*x)/((x*x))+(x)


## 예제 출력 1

x+(x+x+x-x*x)/x
x*x/(x*x)+x