f=lambda u,n:f(f4(u),n-1)if n else u def E(a,b,n): if a4:m=set(f1(w,q)for w in m)|set(f2(w,q)for w in m);e-=1 return m def V(p):p,e=p;return set([(0,p**(e/2))]) while 1: n=input();p=input();S=0 T=p[0][1]if p[0][0]==2 else 0 g=filter(lambda x:(x[0]-1)%4==0,p) h=filter(lambda x:(x[0]-3)%4==0,p) if all(x[1]%2==0 for x in h): if g or h: o=[U(p)for p in g]+[V(p)for p in h] S=[f(x,T)for x in M(o)] else: t=(2**T/2)**.5 S=[0,set([(int(t),int(t))])][t==int(t)] if S:print" = ".join("%d^2 + %d^2"%(x,y)for x,y in sorted(S)) else:print