while 1:n=input();print n,"=",;p=1;exec'p+=1;b=int((n+1)**p**-1)\nif b**p==n:print"%i^%%i"%b%p,\n'*20;print