r='' for s in open(0): i=1 for c in s*9:q=c!='(';i-=1|-q;r=(r+(' ',c)[i==q],r.strip()+c)[c<'('] print(r)