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 copy import deepcopy
def position_point_plan(p):
    if p[0]<=0 and p[1]>0 :
        return 0
    if p[0]<0 and p[1]<=0 :
        return 1
    if p[0]>=0 and p[1]<0 :
        return 2
    if p[0]>0 and p[1]>=0 :
        return 3

def is_parallel(triangle):
    if triangle['s1'][0] in (triangle['s2'][0], triangle['s3'][0]) or triangle['s2'][0]== triangle['s3'][0]:
        return False
    if triangle['s1'][1] in (triangle['s2'][1], triangle['s3'][1]) or triangle['s2'][1]== triangle['s3'][1]:
        return False

    return True
def is_rectangle(triangle):
    return distance(triangle['s2'], triangle['s3']) == math.sqrt(distance(triangle['s1'], triangle['s2'])**2 + distance(triangle['s1'], triangle['s3'])**2)

def distance(p1, p2):
    return math.sqrt((p1[0]- p2[0])**2 + (p1[1] - p2[1])**2)

def rotation_neg_pos(triangle, a, d, p):
    if d > a:
        triangle[p][1] -= 1

    if d < a:
        triangle[p][0] -= 1

def rotation_neg_neg(triangle, a, d, p):
    if d > a:
        triangle[p][0] += 1

    if d < a:
        triangle[p][1] -= 1

def rotation_pos_neg(triangle, a, d, p):
    if d > a:
        triangle[p][1] += 1

    if d < a:
        triangle[p][0] += 1

def rotation_pos_pos(triangle, a, d, p):
    if d > a:
        triangle[p][0] -= 1

    if d < a:
        triangle[p][1] += 1

def rotation_a(triangle, a):
    new_triangle = deepcopy(triangle)
    liste_a=list()
    while(new_triangle['s3'][0]!=0):
        d=distance(new_triangle['s3'], new_triangle['s1'])

        if position_point_plan(new_triangle['s3']) == 0:
            rotation_neg_pos(new_triangle, a, d, 's3')

        elif position_point_plan(new_triangle['s3']) == 1:
            rotation_neg_neg(new_triangle, a, d, 's3')

        elif position_point_plan(new_triangle['s3']) == 2:
            rotation_pos_neg(new_triangle, a, d, 's3')

        else:
            rotation_pos_pos(new_triangle, a, d, 's3')

        if d==a :
            liste_a.append(deepcopy(new_triangle['s3']))

            if position_point_plan(new_triangle['s3']) == 0:
                new_triangle['s3'][0]-=1

            elif position_point_plan(new_triangle['s3']) == 1:
                new_triangle['s3'][1]-=1

            elif position_point_plan(new_triangle['s3']) == 2:
                new_triangle['s3'][0]+=1

            else :
                new_triangle['s3'][1]+=1

    return liste_a


def rotation_b(triangle, b):
    new_triangle = deepcopy(triangle)
    liste_b = list()
    while (new_triangle['s2'][1] != 0):
        d = distance(new_triangle['s2'], new_triangle['s1'])

        if position_point_plan(new_triangle['s2']) == 0:
            rotation_neg_pos(new_triangle, b, d, 's2')

        elif position_point_plan(new_triangle['s2']) == 1:
            rotation_neg_neg(new_triangle, b, d, 's2')

        elif position_point_plan(new_triangle['s2']) == 2:
            rotation_pos_neg(new_triangle, b, d, 's2')

        else:
            rotation_pos_pos(new_triangle, b, d, 's2')

        if d == b:
            liste_b.append(deepcopy(new_triangle['s2']))

            if position_point_plan(new_triangle['s2']) == 0:
                new_triangle['s2'][0] -= 1

            elif position_point_plan(new_triangle['s3']) == 1:
                new_triangle['s2'][1] -= 1

            elif position_point_plan(new_triangle['s2']) == 2:
                new_triangle['s2'][0] += 1

            else:
                new_triangle['s2'][1] += 1

    return liste_b

def yes_no_triangle(triangle, a, b):
    list_a = rotation_a(triangle, a)

    list_b = rotation_b(triangle, b)

    for element_a in list_a:
        for element_b in list_b:
            if is_rectangle({'s1':[0, 0],'s2': element_a, 's3':element_b}) and is_parallel({'s1':[0, 0],'s2': element_a, 's3':element_b}) :
                return True, (0, 0), element_a, element_b
    return False,
def invr():
    return(map(int,input().split()))
if __name__ == '__main__':
    a, b= list(invr())
    triangle={
        "s1": [0, 0],
        "s2": [b, 1],
        "s3": [-1, a]
    }
    res= yes_no_triangle(triangle, a, b)
    if res[0] :
        print('YES')
        print(f'{res[1][0]} {res[1][1]}')
        print(f'{res[2][0]} {res[2][1]}')
        print(f'{res[3][0]} {res[3][1]}')
    else :
        print('NO')