while 1: p='' for n in raw_input().split('x'):b=n<'^'or int(n[1]);a=p and a+p[2:c*3]+`b*int(p[3*c:])`+'x^'[:b-1]+b/3*`~-b`;c=b>1;p=n print a