s='' while 1:r=raw_input(s);i=0;s='';exec"for c in r:x=c>'(';s+=c*(x==i)or' ';i-=x*2-1\ns=s.strip()+'\\n';i-=1\n"*9