import re,os for p,a,b in re.findall('(\D*)(.*?)x\^?(\d)?',os.read(0,9999)):b=int(b or 1);os.write(1,p+`b*int(a)`+'x^'[:b-1]+b/3*`~-b`)