System.in.eachLine{s->f={p,c=s[-1]->def x=19&86%(int)c s-=~/.$/ x<4?{t=f(x&2)+it;p>(x&2)?"($t)":t}(c+f(x)):c} println f(0)}