This problem is about evaluating some C-style expressions. The expressions to be evaluated will contain only simple integer variables and a limited set of operators; there will be no constants in the expressions. There are variables in the program, named by lower case letters through . Before evaluation, the initial values of these variables are a = 1, b = 2, ..., z = 26.
The operators allowed are addition and subtraction (binary and ), with their known meaning. So, the expression a+ c - d + b has the value (1 + 3 - 4 + 2). Additionally, and operators are allowed in the input expression too, which are unary operators, and may come before or after variables. If the operator comes before a variable, then that variable's value is increased (by one) before the variable's value is used in calculating the value of the whole expression. Thus the value of ++ c - b is . When comes after a variable, that variable is increased (by one) after its value is used to calculate the value of the whole expression. So, the value of the c ++ - b is , though is incremented after the value for entire expression is computed; its value will be too. The operator behaves the same way, except that it decreases the value of its operand.
More formally, an expression is evaluated in the following manner:
Identify every variable that is preceded by . Write an assignment statement for incrementing the value of each of them, and omit the from before that variable in the expression.
Do similarly for the variables with after them.
At this point, there is no operator in the expression. Write a statement evaluating the remaining expression after the statements determined in step , and before those determined in step .
Execute the statements determined in step , then those written in step , and finally the one written in step .
This way, evaluating ++ a + b ++ is the same as computing a = a + 1, result = a + b, and b = b + 1.
The first line of the input contains a single integer which is the number of test cases, followed by lines each containing the input expression for a test case. Ignore blanks in the input expression. Be sure that no ambiguity is in the input expressions (like a+++b). Similarly, or operators do not appear both before and after one single variable (like ++a++). You may safely assume each variable appears only once in an expression.
For each test case, write each expression as it appears in the input (exactly), then write the value of the complete expression. After this, on separate lines, write the value of each variable after evaluating the expression (write them in sorted order of the variable names). Write only the values of the variables that are used in the expressions. To find out about the output format, follow the style used in the sample output below.
Example 1