import re while~0: _="" for(s,n,k)in re.findall('(\W)?(\d+)x\^?(\d)?',raw_input()):k=int(k or 1)-1;_+=s+`int(n)*-~k`+("x^%u"%k)[:k*k] print _