while 1: o=[];l=0 for c in raw_input():l-=c>"(";o+=" "*l+c+" "*9,;l+=c<")" for e in zip(*o): f=`e`[2::5].rstrip() if f:print f