x=10667507560001 d={} p=2 exec'for b in range(1832)+[x,x+158]:d[b**p]=d.get(b**p,"=")+" %u^"%b+`p`\np+=1\n'*22 while 1:n=input();print n,d[n]