import os s=[];o='' for c in os.read(0,999): o+=c=='?'and s.pop()or c;i='([{'.find(c) if i+1:s+=[')]}'[i]] print o