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
from math import atan2, pi, cos, sin, degrees, tan, factorial, radians


def get_r(x1, y1, x2, y2):
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2)


def get_ans(x1, y1, x2, y2, x3, y3):
    s1, s2, s3 = get_r(x1, y1, x2, y2), get_r(x2, y2, x3, y3), get_r(x3, y3, x1, y1)
    s1, s2, s3 = list(sorted([s1, s2, s3]))
    if s3 == s1 + s2 and s1 > 0:
        return True
    return False


def main():
    a, b = [int(i) for i in input().split()]
    acc = set()
    bcc = set()
    for i in range(1, 32):
        an = a ** 2 - i ** 2
        bn = b ** 2 - i ** 2
        if an > 0:
            an = round(an ** 0.5, 6)
            if int(an) == an:
                for dx, dy in [[1, -1], [1, 1], [-1, 1], [-1, -1]]:
                    acc.add((dx * int(an), dy * i))
                for dx, dy in [[1, -1], [1, 1], [-1, 1], [-1, -1]]:
                    acc.add((dy * i, dx * int(an)))
        if bn > 0:
            bn = round(bn ** 0.5, 6)
            if int(bn) == bn:
                for dx, dy in [[1, -1], [1, 1], [-1, 1], [-1, -1]]:
                    bcc.add((dx * int(bn), dy * i))
                for dx, dy in [[1, -1], [1, 1], [-1, 1], [-1, -1]]:
                    bcc.add((dy * i, dx * int(bn)))

    acc = list(acc)
    bcc = list(bcc)
    if len(acc) == 0 or len(bcc) == 0:
        print('NO')
        return

    for ax, ay in acc:
        for bx, by in bcc:
            k1, k2 = ax ** 2 + ay ** 2, bx ** 2 + by ** 2
            c = get_r(ax, ay, bx, by)
            if c == k1 + k2 and ax != bx and ay != by:
                print('YES')
                print(0, 0)
                print(ax, ay)
                print(bx, by)
                return


if __name__ == '__main__':
    main()