import re;a=re.sub while 1:print(a('\^1|[-+x]+\d*$','',a('(\d+)x\^((.))',lambda m:eval('str(%s*%s)+"x^"+str(~-%s)'%m.groups()),input())))