F=lambda a,b:a(b)if a<''else'('+a+' '+b+')'if a!='.'else lambda c:lambda d:F(b,F(c,d)) while 1:print reduce(F,raw_input().split())