There is a right triangle with legs of length *a* and *b*. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the appropriate coordinates of vertices.
The first line contains two integers *a*, *b* (1 ≤ *a*, *b* ≤ 1000), separated by a single space.
import math
import timeit
pyth = {}
for i in range(1,1000):
        for j in range(i+1,1000):
                k = math.floor(math.sqrt(i*i + j*j))
                if(k>1000):
                        break
                if(k*k==i*i+j*j):
                        pyth[k] = (i,j)
def ans(c,d):
        global a, b
        if(b*d == -a*c + b*b + a*a):
                return True
        return False

A,B = tuple(int(i) for i in input().split())

if (not A in pyth) or (not B in pyth):
        print("NO")
else:
        a, b = pyth[A]
        #print(pyth[a],pyth[b])
        m, n = pyth[B]

        if(ans(a-m,b-n)):
                print("YES")
                print(0,0)
                print(a,b)
                print(a-m,b-n)
        elif(ans(a-m,n+b)):
                print("YES")
                print(0,0)
                print(a,b)
                print(a-m,n+b)
        elif(ans(m+a,b-n)):
                print("YES")
                print(0,0)
                print(a,b)
                print(m+a,b-n)
        elif(ans(m+a,n+b)):
                print("YES")
                print(0,0)
                print(a,b)
                print(m+a,n+b)
        else:
                t = m
                m = n
                n = t
                if(ans(a-m,b-n)):
                        print("YES")
                        print(0,0)
                        print(a,b)
                        print(a-m,b-n)
                elif(ans(a-m,n+b)):
                        print("YES")
                        print(0,0)
                        print(a,b)
                        print(a-m,n+b)
                elif(ans(m+a,b-n)):
                        print("YES")
                        print(0,0)
                        print(a,b)
                        print(m+a,b-n)
                elif(ans(m+a,n+b)):
                        print("YES")
                        print(0,0)
                        print(a,b)
                        print(m+a,n+b)
                else:
                        print("NO")
