while 1:s=raw_input();i=0;exec"r='';\nfor c in s[::-1]:b=c<')';r=[r and' ',c][b==i]+r;i-=2*b-1\nif r:print r;i-=1\n"*9