---
category_name: school
problem_code: ONP
problem_name: 'Transform the Expression'
languages_supported:
- ADA
- ASM
- BASH
- BF
- C
- 'C99 strict'
- CAML
- CLPS
- 'CPP 4.3.2'
- 'CPP 4.9.2'
- CPP14
- CS2
- D
- ERL
- FORT
- GO
- HASK
- ICK
- ICON
- JAVA
- JS
- 'LISP clisp'
- 'LISP sbcl'
- LUA
- NEM
- NICE
- NODEJS
- 'PAS fpc'
- 'PAS gpc'
- PERL
- PHP
- PIKE
- PRLG
- PYTH
- 'PYTH 3.4'
- RUBY
- SCALA
- 'SCM guile'
- 'SCM qobi'
- ST
- TEXT
- WSPC
max_timelimit: '5'
source_sizelimit: '50000'
problem_author: admin
problem_tester: null
date_added: 1-12-2008
tags:
- admin
time:
view_start_date: 1232460231
submit_start_date: 1232460231
visible_start_date: 1232460231
end_date: 1735669800
current: 1492507635
layout: problem
---
All submissions for this problem are available.Reverse Polish Notation (RPN) is a mathematical notation where every operator follows all of its operands. For instance, to add three and four, one would write "3 4 +" rather than "3 + 4". If there are multiple operations, the operator is given immediately after its second operand; so the expression written "3 − 4 + 5" would be written "3 4 − 5 +" first subtract 4 from 3, then add 5 to that. Transform the algebraic expression with brackets into RPN form.
You can assume that for the test cases below only single letters will be used, brackets \[\] will not be used and each expression has only one RPN form (no expressions like a\*b\*c)
### Input
The first line contains t, the number of test cases (less then 100).
Followed by t lines, containing an expression to be translated to RPN form, where the length of the expression is less then 400.
### Output
<pre>
The <em>expression</em>s in RPN form, one per line.
</pre>### Example
<pre>
Input:
3
(a+(b*c))
((a+b)*(z+x))
((a+t)*((b+(a+c))^(c+d)))
Output:
abc*+
ab+zx+*
at+bac++cd+^*
</pre>