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.
from math import gcd, sqrt

def func(a, b):
    for x in range(1, a):
        if (a * a - x * x) > 0:
             y = int(sqrt(a * a - x * x))
             if x * x + y * y == a * a:
                 g = gcd(x, y)
                 if b % g == 0:
                     return x, y, g
    return None, None, None

a, b = map(int, input().split())
x, y, g = func(a, b)

if x is None or y is None or g is None:
    print("NO")
    exit

if x == a and y == 0 or x == 0 and y == a:
    print("NO")
    exit

b_x = -1 * y * b // g // (a//g)
b_y = x *  b // g // (a//g)

print("YES")
print("0 0")
print(f"{x} {y}")
print(f"{x + b_x} {y + b_y}")# 1691183160.5469596