#1535 Infix-Postfix Conversion

47  10 s   512 MB  

Description

Given an infix expression, convert that into a postfix expression. The operators are "+, -, *, /" and the operands are non-negative integers less than or equal to 108. If the expression is illegal then print out 'syntax error'(without quotation mark). The number of operands in the expression is at most 1000.

Input

Input consists server test cases.

A test case consists combination of the operators, integers, and  brackets. Last character of the test case is '\n'.

If a test case contains the word 'end' then you should ignore the case and finish your program.

 

Output

Output the result of conversion(infix-to- postfix) for each test case. 

 

Sample Input

Sample Output

5 + 65 * 2
7 * ((14-12)*20)
21 + (10 / 3)
5 * (24 + 6) | 155
11+26/3
1237 * 34 + 26 -
1 + 1 + 1 + 1 + 1 
end
5 65 2 * + 
7 14 12 - 20 * * 
21 10 3 / + 
syntax error
11 26 3 / + 
syntax error
1 1 + 1 + 1 + 1 +