f=lambda x,p:0if x>1000else 1000//x+f(x*p,p) print("*".join([f"{n}^{f(n,n)}",str(n)][n>500]for n in range(2,1001)if all(n%d for d in range(2,n))))