#include <stdio.h>
#include <math.h>

int ax,ay,bx,by,tx,ty;

long double distt(long,long);
long double dista(long,long);
long double distb(long,long);
long double max(long double, long double);
main()
{
	extern int ax,ay,bx,by,tx,ty;
	int i,x,y, ai, bi;
	long n, asave, bsave;
	scanf("%d %d %d %d %d %d",&ax,&ay,&bx,&by,&tx,&ty);
	long double total, tdist, asv, bsv, asvmax, bsvmax, asvmax2, bsvmax2, maxsave;
	total = 0;
	scanf("%ld", &n);

	/* 1st bottle */
	scanf("%d %d",&x,&y);
	tdist = distt(x,y);
	total += tdist;
	asvmax = tdist - dista(x,y);
	bsvmax = tdist - distb(x,y);
	asvmax2 = -1e9;
	bsvmax2 = -1e9;
	/* the rest of the bottles */
	for (i = 1; i < n; i++) {
		scanf("%d %d",&x,&y);
		tdist = distt(x,y);
		total += tdist;
		asv = tdist - dista(x,y);
		bsv = tdist - distb(x,y);
		if (asv>asvmax) {
			asvmax2 = asvmax;
			asvmax = asv;
			ai = i;
		} else if (asv>asvmax2) {
			asvmax2 = asv;
		}
		if (bsv>bsvmax) {
			bsvmax2 = bsvmax;
			bsvmax = bsv;
			bi = i;
		} else if (bsv>bsvmax2) {
			bsvmax2 = bsv;
		}
	} // end of for loop

	if (ai == bi) {
		maxsave = max(max(asvmax+bsvmax2, asvmax2+bsvmax),max(asvmax,bsvmax));
	} else {
		maxsave = max(asvmax+bsvmax,max(asvmax,bsvmax));
	}

	printf("%.15Lf\n",total*2 - maxsave);

}

long double dista(long x,long y) {
	return sqrt(pow(x-ax,2)+pow(y-ay,2));
}
long double distb(long x,long y) {
	return sqrt(pow(x-bx,2)+pow(y-by,2));
}
long double distt(long x,long y) {
	return sqrt(pow(x-tx,2)+pow(y-ty,2));
}
long double max(long double a, long double b) {
	return a>b? a:b;
}


#include <stdio.h>
#include <math.h>

int ax,ay,bx,by,tx,ty;

long double distt(long,long);
long double dista(long,long);
long double distb(long,long);
long double max(long double, long double);
main()
{
	extern int ax,ay,bx,by,tx,ty;
	int i,x,y, ai, bi;
	long n, asave, bsave;
	scanf("%d %d %d %d %d %d",&ax,&ay,&bx,&by,&tx,&ty);
	long double total, tdist, asv, bsv, asvmax, bsvmax, asvmax2, bsvmax2, maxsave;
	total = 0;
	scanf("%ld", &n);

	/* 1st bottle */
	scanf("%d %d",&x,&y);
	tdist = distt(x,y);
	total += tdist;
	asvmax = tdist - dista(x,y);
	ai = 0;
	bsvmax = tdist - distb(x,y);
	bi = 0;
	asvmax2 = -1000;
	bsvmax2 = -1000;
	/* the rest of the bottles */
	for (i = 1; i < n; i++) {
		scanf("%d %d",&x,&y);
		tdist = distt(x,y);
		total += tdist;
		asv = tdist - dista(x,y);
		bsv = tdist - distb(x,y);
		if (asv>asvmax) {
			asvmax2 = asvmax;
			asvmax = asv;
			ai = i;
		} else if (asv>asvmax2) {
			asvmax2 = asv;
		}
		if (bsv>bsvmax) {
			bsvmax2 = bsvmax;
			bsvmax = bsv;
			bi = i;
		} else if (bsv>bsvmax2) {
			bsvmax2 = bsv;
		}
	} // end of for loop

	if (ai == bi) {
		maxsave = max(max(asvmax+bsvmax2, asvmax2+bsvmax),max(asvmax,bsvmax));
	} else {
		maxsave = max(asvmax+bsvmax,max(asvmax,bsvmax));
	}
	printf("%.15Lf\n",total*2 - maxsave);

}

long double dista(long x,long y) {
	return sqrt(pow(x-ax,2)+pow(y-ay,2));
}
long double distb(long x,long y) {
	return sqrt(pow(x-bx,2)+pow(y-by,2));
}
long double distt(long x,long y) {
	return sqrt(pow(x-tx,2)+pow(y-ty,2));
}
long double max(long double a, long double b) {
	return a>b? a:b;
}


#include <stdio.h>
#include <math.h>

int ax,ay,bx,by,tx,ty;

long double distt(long,long);
long double dista(long,long);
long double distb(long,long);
long double max(long double, long double);
main()
{
	extern int ax,ay,bx,by,tx,ty;
	int i,x,y, ai, bi;
	long n, asave, bsave;
	scanf("%d %d %d %d %d %d",&ax,&ay,&bx,&by,&tx,&ty);
	long double total, tdist, asv, bsv, asvmax, bsvmax, asvmax2, bsvmax2, maxsave;
	total = 0;
	scanf("%ld", &n);

	/* 1st bottle */
	scanf("%d %d",&x,&y);
	tdist = distt(x,y);
	total += tdist;
	asvmax = tdist - dista(x,y);
	bsvmax = tdist - distb(x,y);
	asvmax2 = -1e10;
	bsvmax2 = -1e10;
	/* the rest of the bottles */
	for (i = 1; i < n; i++) {
		scanf("%d %d",&x,&y);
		tdist = distt(x,y);
		total += tdist;
		asv = tdist - dista(x,y);
		bsv = tdist - distb(x,y);
		if (asv>asvmax) {
			asvmax2 = asvmax;
			asvmax = asv;
			ai = i;
		} else if (asv>asvmax2) {
			asvmax2 = asv;
		}
		if (bsv>bsvmax) {
			bsvmax2 = bsvmax;
			bsvmax = bsv;
			bi = i;
		} else if (bsv>bsvmax2) {
			bsvmax2 = bsv;
		}
	} // end of for loop

	if (ai == bi) {
		printf("amax2 = %Lf, bmax2 = %Lf\n",asvmax2,bsvmax2);
		maxsave = max(max(asvmax+bsvmax2, asvmax2+bsvmax),max(asvmax,bsvmax));
	} else {
		maxsave = max(asvmax+bsvmax,max(asvmax,bsvmax));
	}

	printf("%.15Lf\n",total*2 - maxsave);

}

long double dista(long x,long y) {
	return sqrt(pow(x-ax,2)+pow(y-ay,2));
}
long double distb(long x,long y) {
	return sqrt(pow(x-bx,2)+pow(y-by,2));
}
long double distt(long x,long y) {
	return sqrt(pow(x-tx,2)+pow(y-ty,2));
}
long double max(long double a, long double b) {
	return a>b? a:b;
}


#include <stdio.h>
#include <math.h>

int ax,ay,bx,by,tx,ty;

long double distt(long,long);
long double dista(long,long);
long double distb(long,long);
long double max(long double, long double);
main()
{
	extern int ax,ay,bx,by,tx,ty;
	int i,x,y, ai, bi;
	long n, asave, bsave;
	scanf("%d %d %d %d %d %d",&ax,&ay,&bx,&by,&tx,&ty);
	long double total, tdist, asv, bsv, asvmax, bsvmax, asvmax2, bsvmax2, maxsave;
	total = 0;
	scanf("%ld", &n);

	/* 1st bottle */
	scanf("%d %d",&x,&y);
	tdist = distt(x,y);
	total += tdist;
	asvmax = tdist - dista(x,y);
	bsvmax = tdist - distb(x,y);
	asvmax2 = -1000;
	bsvmax2 = -1000;
	/* the rest of the bottles */
	for (i = 1; i < n; i++) {
		scanf("%d %d",&x,&y);
		tdist = distt(x,y);
		total += tdist;
		asv = tdist - dista(x,y);
		bsv = tdist - distb(x,y);
		if (asv>asvmax) {
			asvmax2 = asvmax;
			asvmax = asv;
			ai = i;
		} else if (asv>asvmax2) {
			asvmax2 = asv;
		}
		if (bsv>bsvmax) {
			bsvmax2 = bsvmax;
			bsvmax = bsv;
			bi = i;
		} else if (bsv>bsvmax2) {
			bsvmax2 = bsv;
		}
	} // end of for loop

	if (ai == bi) {
		maxsave = max(max(asvmax+bsvmax2, asvmax2+bsvmax),max(asvmax,bsvmax));
	} else {
		maxsave = max(asvmax+bsvmax,max(asvmax,bsvmax));
	}

	printf("%.15Lf\n",total*2 - maxsave);

}

long double dista(long x,long y) {
	return sqrt(pow(x-ax,2)+pow(y-ay,2));
}
long double distb(long x,long y) {
	return sqrt(pow(x-bx,2)+pow(y-by,2));
}
long double distt(long x,long y) {
	return sqrt(pow(x-tx,2)+pow(y-ty,2));
}
long double max(long double a, long double b) {
	return a>b? a:b;
}


#include <stdio.h>
#include <math.h>

int ax,ay,bx,by,tx,ty;

long double distt(long,long);
long double dista(long,long);
long double distb(long,long);
long double max(long double, long double);
main()
{
	extern int ax,ay,bx,by,tx,ty;
	int i,x,y, ai, bi;
	long n, asave, bsave;
	scanf("%d %d %d %d %d %d",&ax,&ay,&bx,&by,&tx,&ty);
	long double total, tdist, asv, bsv, asvmax, bsvmax, asvmax2, bsvmax2, maxsave;
	total = 0;
	scanf("%ld", &n);

	/* 1st bottle */
	scanf("%d %d",&x,&y);
	tdist = distt(x,y);
	total += tdist;
	asvmax = tdist - dista(x,y);
	bsvmax = tdist - distb(x,y);

	/* the rest of the bottles */
	for (i = 1; i < n; i++) {
		scanf("%d %d",&x,&y);
		tdist = distt(x,y);
		total += tdist;
		asv = tdist - dista(x,y);
		bsv = tdist - distb(x,y);
		if (asv>asvmax) {
			asvmax2 = asvmax;
			asvmax = asv;
			ai = i;
		} else if (asv>asvmax2) {
			asvmax2 = asv;
		}
		if (bsv>bsvmax) {
			bsvmax2 = bsvmax;
			bsvmax = bsv;
			bi = i;
		} else if (bsv>bsvmax2) {
			bsvmax2 = bsv;
		}
	} // end of for loop

	if (ai == bi) {
		maxsave = max(max(asvmax+bsvmax2, asvmax2+bsvmax),max(asvmax,bsvmax));
	} else {
		maxsave = max(asvmax+bsvmax,max(asvmax,bsvmax));
	}

	printf("%.15Lf\n",total*2 - maxsave);

}

long double dista(long x,long y) {
	return sqrt(pow(x-ax,2)+pow(y-ay,2));
}
long double distb(long x,long y) {
	return sqrt(pow(x-bx,2)+pow(y-by,2));
}
long double distt(long x,long y) {
	return sqrt(pow(x-tx,2)+pow(y-ty,2));
}
long double max(long double a, long double b) {
	return a>b? a:b;
}


#include <stdio.h>
#include <math.h>

#define N 100000

typedef long long ll;

ll x[N], y[N];

double dist(ll x1, ll y1, ll x2, ll y2) {
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

double min(double x, double y) {
    return x < y ? x : y;
}

int main(int argc, char* argv[]) {
    int i, n, aid, bid;
    ll ax, ay, bx, by, tx, ty;
    double total = 0, ans = 1e60;
    double ad1, ad2, bd1, bd2;

    scanf("%I64d%I64d%I64d%I64d%I64d%I64d", &ax, &ay, &bx, &by, &tx, &ty);
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%I64d%I64d", &x[i], &y[i]);
        total += 2 * dist(x[i], y[i], tx, ty);
    }

    ad1 = ad2 = 1e60;
    for (i = 0; i < n; i++) {
        double diff = dist(x[i], y[i], ax, ay) - dist(x[i], y[i], tx, ty);
        double local_ans = total + diff;
        ans = min(ans, local_ans);
        if (diff < ad1) {
            aid = i;
            ad2 = ad1;
            ad1 = diff;
        }
        else if (diff < ad2)
            ad2 = diff;
    }

    bd1 = bd2 = 1e60;
    for (i = 0; i < n; i++) {
        double diff = dist(x[i], y[i], bx, by) - dist(x[i], y[i], tx, ty);
        double local_ans = total + diff;
        ans = min(ans, local_ans);
        if (diff < bd1) {
            bid = i;
            bd2 = bd1;
            bd1 = diff;
        }
        else if (diff < bd2)
            bd2 = diff;
    }

    if (aid == bid) {
        ans = min(ans, total + ad1 + bd2);
        ans = min(ans, total + ad2 + bd1);
    }
    else
        ans = min(ans, total + ad1 + bd1);

    printf("%.12f\n", ans);

    return 0;
}


package main

import (
	"bufio"
	. "fmt"
	"io"
	"math"
	"os"
	"sort"
)

type vec struct {
	x, y int
}

func (a vec) sub(b vec) vec { return vec{a.x - b.x, a.y - b.y} }
func (a vec) len() float64  { return math.Hypot(float64(a.x), float64(a.y)) }

// github.com/EndlessCheng/codeforces-go
func Sol671A(reader io.Reader, writer io.Writer) {
	type pair struct {
		d   float64
		idx int
	}
	read := func(in io.Reader) vec {
		var x, y int
		Fscan(in, &x, &y)
		return vec{x, y}
	}
	max := func(a, b float64) float64 {
		if a > b {
			return a
		}
		return b
	}
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	pa, pb, bin := read(in), read(in), read(in)
	pa = pa.sub(bin)
	pb = pb.sub(bin)
	var n int
	Fscan(in, &n)
	das := make([]pair, n)
	dbs := make([]pair, n)
	ans := 0.0
	for i := range das {
		p := read(in).sub(bin)
		lenP := p.len()
		ans += lenP
		das[i] = pair{lenP - p.sub(pa).len(), i}
		dbs[i] = pair{lenP - p.sub(pb).len(), i}
	}
	ans *= 2

	sort.Slice(das, func(i, j int) bool { return das[i].d > das[j].d })
	sort.Slice(dbs, func(i, j int) bool { return dbs[i].d > dbs[j].d })
	if n == 1 || das[0].d <= 0 || dbs[0].d <= 0 {
		ans -= max(das[0].d, dbs[0].d)
	} else if das[0].idx == dbs[0].idx {
		sum1 := das[0].d
		sum2 := dbs[0].d
		if dbs[1].d > 0 {
			sum1 += dbs[1].d
		}
		if das[1].d > 0 {
			sum2 += das[1].d
		}
		ans -= max(sum1, sum2)
	} else {
		ans -= das[0].d + dbs[0].d
	}
	Fprintf(out, "%.12f", ans)
}

func main() {
	Sol671A(os.Stdin, os.Stdout)
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func sqr(a int) int64 {
	return int64(a) * int64(a)
}
func dist(ax, ay, bx, by int) float64 {
	return math.Sqrt(float64(sqr(ax-bx) + sqr(ay-by)))
}

const Inf = 1000000001

func main() {
	ax, ay, bx, by, tx, ty, n := getInt(), getInt(), getInt(), getInt(), getInt(), getInt(), getInt()

	var dsum float64
	const ival = -4.0 * Inf * Inf
	var ansa, ansb struct {
		best, next float64
		idx        int
	}
	ansa.best, ansa.next, ansb.best, ansb.next = ival, ival, ival, ival

	for i := 0; i < n; i++ {
		px, py := getInt(), getInt()
		t := dist(tx, ty, px, py)
		a := t - dist(ax, ay, px, py)
		b := t - dist(bx, by, px, py)
		dsum += t

		if a > ansa.best {
			ansa.next = ansa.best
			ansa.best = a
			ansa.idx = i
		} else if a > ansa.next {
			ansa.next = a
		}
		if b > ansb.best {
			ansb.next = ansb.best
			ansb.best = b
			ansb.idx = i
		} else if b > ansb.next {
			ansb.next = b
		}
	}
	dsum *= 2

	a, b := ansa.best, ansb.best
	ans := math.Max(a, b) // only one

	// two
	if ansa.idx != ansb.idx {
		ans = math.Max(ans, a+b)
	} else {
		ans = math.Max(ans, math.Max(a+ansb.next, b+ansa.next))
	}

	fmt.Printf("%.7f\n", dsum-ans)
}

type Input struct {
	*bufio.Scanner
}

var globalInput = wrapStdin()

func wrapStdin() Input {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return Input{Scanner: sc}
}
func getWord() string {
	globalInput.Scan()
	return globalInput.Text()
}
func getInt() int {
	globalInput.Scan()
	x, _ := strconv.Atoi(globalInput.Text())
	return x
}
func getIntOk() (int, bool) {
	ok := globalInput.Scan()
	x, _ := strconv.Atoi(globalInput.Text())
	return x, ok
}
func getNint(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		v[i] = getInt()
	}
	return v
}
func getVint(v []int) bool {
	var ok bool
	for i := 0; i < len(v); i++ {
		v[i], ok = getIntOk()
	}
	return ok
}


import java.math.*;
import java.io.*;
public class C408C{
   public static void main(String[] args) throws IOException{
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      String[] num1=br.readLine().split(" ");
      int A=Integer.parseInt(num1[0]);
      int B=Integer.parseInt(num1[1]);
      int x1=0;
      int y1=0;
      for(int x=1;x<A;x++)
         if((int)Math.sqrt((double)(A*A-x*x))*(int)Math.sqrt((double)(A*A-x*x))+x*x==A*A){
            x1=x;
            y1=(int)Math.sqrt((double)(A*A-x*x));
         }
      int x2=0;
      int y2=0;
      for(int x=1;x<B;x++)
         if(x*x1%y1==0)
            if(x*x+(x*x1/y1)*(x*x1/y1)==B*B){
               x2=x;
               y2=-x*x1/y1;
            }
      if(x1!=0 && x2!=0){
         System.out.println("YES");
         System.out.println("0 0");
         System.out.println(x1+" "+y1);
         System.out.println(x2+" "+y2);
      }
      else System.out.println("NO");
   }
}


import java.math.*;
import java.io.*;
public class C408C{
   public static void main(String[] args) throws IOException{
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      String[] num1=br.readLine().split(" ");
      int A=Integer.parseInt(num1[0]);
      int B=Integer.parseInt(num1[1]);
      int fx1=0;
      int fy1=0;
      int fx2=0;
      int fy2=0;
      for(int x=1;x<A;x++)
         if((int)Math.sqrt((double)(A*A-x*x))*(int)Math.sqrt((double)(A*A-x*x))+x*x==A*A){
            int x1=x;
            int y1=(int)Math.sqrt((double)(A*A-x*x));
            for(int y=1;y<B;y++)
               if(y*x1%y1==0)
                  if(y*y+(y*x1/y1)*(y*x1/y1)==B*B){
                     if(y==x1){
                        if(y*x1/y1!=y1){
                           fx1=x1;
                           fy1=y1;
                           fx2=-y;
                           fy2=y*x1/y1;
                        }
                     }
                     else{
                        fx1=x1;
                        fy1=y1;
                        fx2=y;
                        fy2=-y*x1/y1;
                     }
                  }
         }
      if(fx1!=0 && fx2!=0){
         System.out.println("YES");
         System.out.println("0 0");
         System.out.println(fx1+" "+fy1);
         System.out.println(fx2+" "+fy2);
      }
      else System.out.println("NO");
   }
}


import java.math.*;
import java.io.*;
public class C408C{
   public static void main(String[] args) throws IOException{
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      String[] num1=br.readLine().split(" ");
      int A=Integer.parseInt(num1[0]);
      int B=Integer.parseInt(num1[1]);
      int fx1=0;
      int fy1=0;
      int fx2=0;
      int fy2=0;
      for(int x=1;x<A;x++)
         if((int)Math.sqrt((double)(A*A-x*x))*(int)Math.sqrt((double)(A*A-x*x))+x*x==A*A){
            int x1=x;
            int y1=(int)Math.sqrt((double)(A*A-x*x));
            for(int y=1;y<B;y++)
               if(y*x1%y1==0)
                  if(y*y+(y*x1/y1)*(y*x1/y1)==B*B){
                     fx1=x1;
                     fy1=y1;
                     fx2=y;
                     fy2=-y*x1/y1;
                  }
         }
      if(fx1!=0 && fx2!=0){
         System.out.println("YES");
         System.out.println("0 0");
         System.out.println(fx1+" "+fy1);
         System.out.println(fx2+" "+fy2);
      }
      else System.out.println("NO");
   }
}


import java.util.Scanner;

public class test {
    public static int gcd(int a, int b) {
        int max = a;
        int res = 1;
        if (b > a)
            max = b;
        for (int i = 2; i <= max; i++) {
            if ((a % i == 0) && (b % i == 0))
                res = i;
        }
        return res;
    }
    public static void main(String args[]) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        input.close();
        double c = a * a + b * b;
        int xA = 0, yA = 0;
        for (int i = 1; i < a; i++) {
            for (int j = 1; j < a; j++) {
                if (i*i + j*j == a * a) {
                    xA = i;
                    yA = j;
                    int d = gcd(xA, yA);
                    int xB = -yA / d;
                    int yB = xA / d;
                    double lenB = Math.sqrt(xB*xB + yB*yB);
                    if (lenB == (int)lenB && (yA != yB)) {
                        System.out.println(0 + " " + 0);
                        System.out.println(xA + " " + yA);
                        System.out.println((xB * b) / (int)lenB + " " + (yB * b) / (int)lenB);
                        return;
                    }
                }
            }
        }
        System.out.print("NO");
    }
}


import java.util.Scanner;

public class test {
    public static int gcd(int a, int b) {
        int max = a;
        int res = 1;
        if (b > a)
            max = b;
        for (int i = 2; i <= max; i++) {
            if ((a % i == 0) && (b % i == 0))
                res = i;
        }
        return res;
    }
    public static void main(String args[]) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        input.close();
        double c = a * a + b * b;
        int xA = 0, yA = 0;
        for (int i = 1; i < a; i++) {
            for (int j = 1; j < a; j++) {
                if (i*i + j*j == a * a) {
                    xA = i;
                    yA = j;
                    int d = gcd(xA, yA);
                    int xB = -yA / d;
                    int yB = xA / d;
                    double lenB = Math.sqrt(xB*xB + yB*yB);
                    if (lenB == (int)lenB && (yA != yB)) {
                        System.out.println("YES");
                        System.out.println(0 + " " + 0);
                        System.out.println(xA + " " + yA);
                        System.out.println((xB * b) / (int)lenB + " " + (yB * b) / (int)lenB);
                        return;
                    }
                }
            }
        }
        System.out.print("NO");
    }
}


import java.util.Scanner;

public class test {

    public static void main(String args[]) {
        Scanner input = new Scanner(System.in);
        double a = input.nextInt();
        double b = input.nextInt();
        input.close();
        double c = a * a + b * b;
        double xA = 0, yA = 0, xB = 0, yB = 0;
        for (int i = 1; i < a; i++) {
            if (Math.sqrt(a * a - i * i) == (int)Math.sqrt(a * a - i * i)) {
                xA = i;
                yA = Math.sqrt(a * a - i * i);
                //System.out.println(xA + " " + yA);
                for (int j = 1; j < c; j++) {
                    if (Math.sqrt(c - j * j) == (int)Math.sqrt(c - j * j)) {
                        //System.out.println(j + " " + Math.sqrt(c - j * j));
                        xB = xA - Math.sqrt(c - j * j);
                        yB = yA + j;
                        if (xB * xB + yB * yB != b * b)
                            yB = yA - j;
                        //System.out.println(xB + " " + yB);
                        double lenNorm = Math.sqrt(xA * xA + yA * yA);
                        //System.out.println(lenNorm);
                        if (xB / (-yA / lenNorm) == b && yB / (xA / lenNorm) == b) {
                            System.out.println("YES");
                            System.out.println(0 + " " + 0);
                            System.out.println((int)xA + " " + (int)yA);
                            System.out.println((int)xB + " " + (int)yB);
                            return;
                        }
                    }
                }
                //System.out.println();
            }
        }
        System.out.print("NO");
    }
}


import java.util.Scanner;

public class test {
    public static int gcd(int a, int b) {
        int max = a;
        int res = 1;
        if (b > a)
            max = b;
        for (int i = 2; i <= max; i++) {
            if ((a % i == 0) && (b % i == 0))
                res = i;
        }
        return res;
    }
    public static void main(String args[]) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        input.close();
        double c = a * a + b * b;
        int xA = 0, yA = 0;
        for (int i = 1; i < a; i++) {
            for (int j = 1; j < a; j++) {
                if (i*i + j*j == a * a) {
                    xA = i;
                    yA = j;
                    int d = gcd(xA, yA);
                    int xB = -yA / d;
                    int yB = xA / d;
                    double lenB = Math.sqrt(xB*xB + yB*yB);
                    if (lenB == (int)lenB && (yA != yB)) {
                        System.out.print("YES");
                        System.out.println(0 + " " + 0);
                        System.out.println(xA + " " + yA);
                        System.out.println((xB * b) / (int)lenB + " " + (yB * b) / (int)lenB);
                        return;
                    }
                }
            }
        }
        System.out.print("NO");
    }
}


import java.util.Scanner;

public class test {

    public static void main(String args[]) {
        Scanner input = new Scanner(System.in);
        double a = input.nextInt();
        double b = input.nextInt();
        input.close();
        double c = a * a + b * b;
        double xA = 0, yA = 0, xB = 0, yB = 0;
        for (int i = 1; i < a; i++) {
            if (Math.sqrt(a * a - i * i) == (int)Math.sqrt(a * a - i * i)) {
                xA = i;
                yA = Math.sqrt(a * a - i * i);
                //System.out.println(xA + " " + yA);
                for (int j = 1; j < c; j++) {
                    if (Math.sqrt(c - j * j) == (int)Math.sqrt(c - j * j)) {
                        //System.out.println(j + " " + Math.sqrt(c - j * j));
                        xB = xA - Math.sqrt(c - j * j);
                        yB = yA + j;
                        //System.out.println(xA - Math.sqrt(c - j * j) + " " + (yA + j));
                        double lenNorm = Math.sqrt(xA * xA + yA * yA);
                        //System.out.println(lenNorm);
                        if (xB / (-yA / lenNorm) == b && yB / (xA / lenNorm) == b) {
                            System.out.println("YES");
                            System.out.println(0 + " " + 0);
                            System.out.println((int)xA + " " + (int)yA);
                            System.out.println((int)xB + " " + (int)yB);
                            return;
                        }
                    }
                }

            }

        }
        System.out.print("NO");
    }
}


import java.util.Scanner;

public class test {

    public static void main(String args[]) {
        Scanner input = new Scanner(System.in);
        double a = input.nextInt();
        double b = input.nextInt();
        input.close();
        double c = a * a + b * b;
        double xA = 0, yA = 0, xB = 0, yB = 0, xC = 0, yC = 0;
        for (int i = 1; i < a; i++) {
            for (int j = 1; j < a; j++) {
                if (i*i + j*j == a * a) {
                    xA = i;
                    yA = j;
                    xB = Math.cos(Math.PI - Math.acos(yA/a)) * b;
                    yB = Math.sqrt(b*b - xB*xB);
                    if ((int)xB == xB && (int)yB == yB && (yA != yB)) {
                        if (((xA - xB)*(xA - xB) + (yA - yB)*(yA - yB)) == c) {
                            System.out.println("YES");
                            System.out.println(0 + " " + 0);
                            System.out.println((int)xA + " " + (int)yA);
                            System.out.println((int)xB + " " + (int)yB);
                            return;
                        }
                    }
                }
            }
        }
        System.out.print("NO");
    }
}


import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class solver implements Runnable {
        final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
        BufferedReader in;
        PrintWriter out;
        StringTokenizer tok = new StringTokenizer("");

        void init() throws FileNotFoundException{
            if (ONLINE_JUDGE){
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
           }else{
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
           }
        }
        String readString() throws IOException{
                while(!tok.hasMoreTokens()){
                        try{
                                tok = new StringTokenizer(in.readLine());
                        }catch (Exception e){
                                return null;
                        }
                }
                return tok.nextToken();
        }
        String readString(String delim) throws IOException{
            while(!tok.hasMoreTokens()){
                    try{
                            tok = new StringTokenizer(in.readLine());
                    }catch (Exception e){
                            return null;
                    }
            }
            return tok.nextToken(delim);
    }

        int readInt() throws IOException{
                return Integer.parseInt(readString());
        }
        int readInt(String delim) throws IOException{
            return Integer.parseInt(readString(delim));
        }
        long readLong() throws IOException{
                return Long.parseLong(readString());
        }
        long readLong(String delim) throws IOException{
            return Long.parseLong(readString(delim));
        }
        double readDouble() throws IOException{
                return Double.parseDouble(readString());
        }
        double readDouble(String delim) throws IOException{
            return Double.parseDouble(readString(delim));
        }
        char readChar() throws IOException {
            char val = 0;
            do{
                val = (char) in.read();
            }while(val == '\n' || val == '\r');
            return val;
        }
        char readChar(String skipChars)throws IOException{
            char val = 0;
            boolean ret;
            do{
                val = (char) in.read();
                ret = false;
                for (int i = skipChars.length()-1; i >= 0; i--){
                    if (skipChars.charAt(i) == val){
                        ret = true;
                        break;
                    }
                }
            }while(ret);
            return val;
        }

        public class Pair<T1,T2> {
            public T1 x1;
            public T2 x2;
            public Pair(){};
            public Pair(T1 x1, T2 x2){
                this.x1 = x1;
                this.x2 = x2;
            }
            public String toString(){
                return x1.toString() + " " + x2.toString();
            }
        }
        public class Point implements Comparable<Point>{
            public int x1, x2;
            public Point(){}
            public Point(int a, int b){x1 = a;x2=b;}
            public int compareTo(Point o) {
                return x1-o.x1;
            }
            public String toString(){
                return x1 + " " + x2;
            }
        }
 //----------------------------------------

        Point getPif(int a, int i){
            int aa  = a*a;
            int ii;
            for (;i*i + 1 <= aa ;i++){
                ii = i*i;
                int cc = aa - ii;
                int c = (int) Math.sqrt(cc);
                cc=c*c;

                if (cc + ii == aa){
                    return new Point(i,c);
                }
            }
            return null;
        }

        public void solve() throws IOException {
            int a = readInt();
            int b = readInt();

            int mm;
            if (b < a){
                mm = b;
                b = a;
                a = mm;
            }

            int i = 1;

            int aa = a*a;
            int bb = b*b;
            int ii, kk, zz;
            while(true){

                Point p = getPif(b, i);
                if (p == null){
                    break;
                }

                i = p.x1;
                ii = i*i;
                int k = p.x2;
                kk = k*k;

                int z = (int) (a*k/Math.sqrt(ii+kk));
                zz = z*z;
                if (aa*kk != zz*(ii+kk)){
                    continue;
                }

                int m = (int) Math.sqrt(aa - zz);
                mm = m*m;
                if (mm + zz != aa) continue;
                if (m == k) continue;

                out.println("YES");
                out.println("0 " + i);
                out.println(k +" 0");
                out.println((m) +" " + (i+z));
                return;
            }
            out.print("NO");
        }

//----------------------------------------
        public static void main(String[] args){
                new Thread(null, new solver(), "", 256 * (1L << 20)).start();
        }

        long timeBegin, timeEnd;

        void time(){
                timeEnd = System.currentTimeMillis();
                System.err.println("Time = " + (timeEnd - timeBegin));
        }

        public void run(){
                try{
                        timeBegin = System.currentTimeMillis();
                        init();
                        solve();
                        out.close();
                        time();
                }catch (Exception e){
                        e.printStackTrace(System.err);
                        System.exit(-1);
                }
        }
}


import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class solver implements Runnable {
        final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
        BufferedReader in;
        PrintWriter out;
        StringTokenizer tok = new StringTokenizer("");

        void init() throws FileNotFoundException{
            if (ONLINE_JUDGE){
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
           }else{
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
           }
        }
        String readString() throws IOException{
                while(!tok.hasMoreTokens()){
                        try{
                                tok = new StringTokenizer(in.readLine());
                        }catch (Exception e){
                                return null;
                        }
                }
                return tok.nextToken();
        }
        String readString(String delim) throws IOException{
            while(!tok.hasMoreTokens()){
                    try{
                            tok = new StringTokenizer(in.readLine());
                    }catch (Exception e){
                            return null;
                    }
            }
            return tok.nextToken(delim);
    }

        int readInt() throws IOException{
                return Integer.parseInt(readString());
        }
        int readInt(String delim) throws IOException{
            return Integer.parseInt(readString(delim));
        }
        long readLong() throws IOException{
                return Long.parseLong(readString());
        }
        long readLong(String delim) throws IOException{
            return Long.parseLong(readString(delim));
        }
        double readDouble() throws IOException{
                return Double.parseDouble(readString());
        }
        double readDouble(String delim) throws IOException{
            return Double.parseDouble(readString(delim));
        }
        char readChar() throws IOException {
            char val = 0;
            do{
                val = (char) in.read();
            }while(val == '\n' || val == '\r');
            return val;
        }
        char readChar(String skipChars)throws IOException{
            char val = 0;
            boolean ret;
            do{
                val = (char) in.read();
                ret = false;
                for (int i = skipChars.length()-1; i >= 0; i--){
                    if (skipChars.charAt(i) == val){
                        ret = true;
                        break;
                    }
                }
            }while(ret);
            return val;
        }

        public class Pair<T1,T2> {
            public T1 x1;
            public T2 x2;
            public Pair(){};
            public Pair(T1 x1, T2 x2){
                this.x1 = x1;
                this.x2 = x2;
            }
            public String toString(){
                return x1.toString() + " " + x2.toString();
            }
        }
        public class Point implements Comparable<Point>{
            public int x1, x2;
            public Point(){}
            public Point(int a, int b){x1 = a;x2=b;}
            public int compareTo(Point o) {
                return x1-o.x1;
            }
            public String toString(){
                return x1 + " " + x2;
            }
        }
 //----------------------------------------

        Point getPif(int a, int i){
            int aa  = a*a;
            int ii;
            for (;i*i + 1 <= aa ;i++){
                ii = i*i;
                int cc = aa - ii;
                int c = (int) Math.sqrt(cc);
                cc=c*c;

                if (cc + ii == aa){
                    return new Point(i,c);
                }
            }
            return null;
        }

        public void solve() throws IOException {
            int a = readInt();
            int b = readInt();

            int mm;
            if (b > a){
                mm = b;
                b = a;
                a = mm;
            }

            int i = 1;

            int aa = a*a;
            int bb = b*b;
            int ii, kk, zz;
            while(true){

                Point p = getPif(b, i);
                if (p == null){
                    break;
                }

                i = p.x1;
                ii = i*i;
                int k = p.x2;
                kk = k*k;

                int z = (int) (a*k/Math.sqrt(ii+kk));
                zz = z*z;
                if (aa*kk != zz*(ii+kk)){
                    continue;
                }

                int m = (int) Math.sqrt(aa - zz);
                mm = m*m;
                if (mm + zz != aa) continue;
                if (m == k) continue;

                out.println("YES");
                out.println("0 " + i);
                out.println(k +" 0");
                out.println((m) +" " + (i+z));
                return;
            }
            out.print("NO");
        }

//----------------------------------------
        public static void main(String[] args){
                new Thread(null, new solver(), "", 256 * (1L << 20)).start();
        }

        long timeBegin, timeEnd;

        void time(){
                timeEnd = System.currentTimeMillis();
                System.err.println("Time = " + (timeEnd - timeBegin));
        }

        public void run(){
                try{
                        timeBegin = System.currentTimeMillis();
                        init();
                        solve();
                        out.close();
                        time();
                }catch (Exception e){
                        e.printStackTrace(System.err);
                        System.exit(-1);
                }
        }
}


import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class solver implements Runnable {
        final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
        BufferedReader in;
        PrintWriter out;
        StringTokenizer tok = new StringTokenizer("");

        void init() throws FileNotFoundException{
            if (ONLINE_JUDGE){
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
           }else{
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
           }
        }
        String readString() throws IOException{
                while(!tok.hasMoreTokens()){
                        try{
                                tok = new StringTokenizer(in.readLine());
                        }catch (Exception e){
                                return null;
                        }
                }
                return tok.nextToken();
        }
        String readString(String delim) throws IOException{
            while(!tok.hasMoreTokens()){
                    try{
                            tok = new StringTokenizer(in.readLine());
                    }catch (Exception e){
                            return null;
                    }
            }
            return tok.nextToken(delim);
    }

        int readInt() throws IOException{
                return Integer.parseInt(readString());
        }
        int readInt(String delim) throws IOException{
            return Integer.parseInt(readString(delim));
        }
        long readLong() throws IOException{
                return Long.parseLong(readString());
        }
        long readLong(String delim) throws IOException{
            return Long.parseLong(readString(delim));
        }
        double readDouble() throws IOException{
                return Double.parseDouble(readString());
        }
        double readDouble(String delim) throws IOException{
            return Double.parseDouble(readString(delim));
        }
        char readChar() throws IOException {
            char val = 0;
            do{
                val = (char) in.read();
            }while(val == '\n' || val == '\r');
            return val;
        }
        char readChar(String skipChars)throws IOException{
            char val = 0;
            boolean ret;
            do{
                val = (char) in.read();
                ret = false;
                for (int i = skipChars.length()-1; i >= 0; i--){
                    if (skipChars.charAt(i) == val){
                        ret = true;
                        break;
                    }
                }
            }while(ret);
            return val;
        }

        public class Pair<T1,T2> {
            public T1 x1;
            public T2 x2;
            public Pair(){};
            public Pair(T1 x1, T2 x2){
                this.x1 = x1;
                this.x2 = x2;
            }
            public String toString(){
                return x1.toString() + " " + x2.toString();
            }
        }
        public class Point implements Comparable<Point>{
            public int x1, x2;
            public Point(){}
            public Point(int a, int b){x1 = a;x2=b;}
            public int compareTo(Point o) {
                return x1-o.x1;
            }
            public String toString(){
                return x1 + " " + x2;
            }
        }
 //----------------------------------------

        Point getPif(int a, int i){
            int aa  = a*a;
            for (;i*i + 1 <= aa ;i++){

                int cc = aa - i*i;
                int c = (int) Math.sqrt(cc);

                if (c*c + i*i == aa){
                    return new Point(i,c);
                }
            }
            return null;
        }

        public void solve() throws IOException {
            int a = readInt();
            int b = readInt();

            int i = 1;
            while(true){

                Point p = getPif(b, i);
                if (p == null){
                    break;
                }

                i = p.x1;
                int k = p.x2;

                int z = (int) (a*k/Math.sqrt(i*i+k*k));
                if (a*a*k*k != z*z*(i*i+k*k)){
                    continue;
                }

                int m = (int) Math.sqrt(a*a - z*z);
                if (m*m + z*z != a*a) continue;
                if (m == k) continue;

                out.println("YES");
                out.println("0 " + i);
                out.println(k +" 0");
                out.println((m) +" " + (i+z));
                return;
            }
            out.print("NO");
        }

//----------------------------------------
        public static void main(String[] args){
                new Thread(null, new solver(), "", 256 * (1L << 20)).start();
        }

        long timeBegin, timeEnd;

        void time(){
                timeEnd = System.currentTimeMillis();
                System.err.println("Time = " + (timeEnd - timeBegin));
        }

        public void run(){
                try{
                        timeBegin = System.currentTimeMillis();
                        init();
                        solve();
                        out.close();
                        time();
                }catch (Exception e){
                        e.printStackTrace(System.err);
                        System.exit(-1);
                }
        }
}


import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class solver implements Runnable {
        final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
        BufferedReader in;
        PrintWriter out;
        StringTokenizer tok = new StringTokenizer("");

        void init() throws FileNotFoundException{
            if (ONLINE_JUDGE){
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
           }else{
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
           }
        }
        String readString() throws IOException{
                while(!tok.hasMoreTokens()){
                        try{
                                tok = new StringTokenizer(in.readLine());
                        }catch (Exception e){
                                return null;
                        }
                }
                return tok.nextToken();
        }
        String readString(String delim) throws IOException{
            while(!tok.hasMoreTokens()){
                    try{
                            tok = new StringTokenizer(in.readLine());
                    }catch (Exception e){
                            return null;
                    }
            }
            return tok.nextToken(delim);
    }

        int readInt() throws IOException{
                return Integer.parseInt(readString());
        }
        int readInt(String delim) throws IOException{
            return Integer.parseInt(readString(delim));
        }
        long readLong() throws IOException{
                return Long.parseLong(readString());
        }
        long readLong(String delim) throws IOException{
            return Long.parseLong(readString(delim));
        }
        double readDouble() throws IOException{
                return Double.parseDouble(readString());
        }
        double readDouble(String delim) throws IOException{
            return Double.parseDouble(readString(delim));
        }
        char readChar() throws IOException {
            char val = 0;
            do{
                val = (char) in.read();
            }while(val == '\n' || val == '\r');
            return val;
        }
        char readChar(String skipChars)throws IOException{
            char val = 0;
            boolean ret;
            do{
                val = (char) in.read();
                ret = false;
                for (int i = skipChars.length()-1; i >= 0; i--){
                    if (skipChars.charAt(i) == val){
                        ret = true;
                        break;
                    }
                }
            }while(ret);
            return val;
        }

        public class Pair<T1,T2> {
            public T1 x1;
            public T2 x2;
            public Pair(){};
            public Pair(T1 x1, T2 x2){
                this.x1 = x1;
                this.x2 = x2;
            }
            public String toString(){
                return x1.toString() + " " + x2.toString();
            }
        }
        public class Point implements Comparable<Point>{
            public int x1, x2;
            public Point(){}
            public Point(int a, int b){x1 = a;x2=b;}
            public int compareTo(Point o) {
                return x1-o.x1;
            }
            public String toString(){
                return x1 + " " + x2;
            }
        }
 //----------------------------------------

        Point getPif(int a, int i){
            int aa  = a*a;
            int ii;
            for (;i*i + 1 <= aa ;i++){
                ii = i*i;
                int cc = aa - ii;
                int c = (int) Math.sqrt(cc);
                cc=c*c;

                if (cc + ii == aa){
                    return new Point(i,c);
                }
            }
            return null;
        }

        public void solve() throws IOException {
            int a = readInt();
            int b = readInt();

            int mm;
            if (b < a){
                mm = b;
                b = a;
                a = mm;
            }

            int i = 0;

            int aa = a*a;
            int bb = b*b;
            int ii, kk, zz;
            while(true){

                Point p = getPif(b, i+1);
                if (p == null){
                    break;
                }

                i = p.x1;
                ii = i*i;
                int k = p.x2;
                kk = k*k;

                int z = (int) (a*k/Math.sqrt(ii+kk));
                zz = z*z;
                if (aa*kk != zz*(ii+kk)){
                    continue;
                }

                int m = (int) Math.sqrt(aa - zz);
                mm = m*m;
                if (mm + zz != aa) continue;
                if (m == k) continue;

                out.println("YES");
                out.println("0 " + i);
                out.println(k +" 0");
                out.println((m) +" " + (i+z));
                return;
            }
            out.print("NO");
        }

//----------------------------------------
        public static void main(String[] args){
                new Thread(null, new solver(), "", 256 * (1L << 20)).start();
        }

        long timeBegin, timeEnd;

        void time(){
                timeEnd = System.currentTimeMillis();
                System.err.println("Time = " + (timeEnd - timeBegin));
        }

        public void run(){
                try{
                        timeBegin = System.currentTimeMillis();
                        init();
                        solve();
                        out.close();
                        time();
                }catch (Exception e){
                        e.printStackTrace(System.err);
                        System.exit(-1);
                }
        }
}


import java.util.*;
public class C {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a > b) { int tmp = a; a = b; b = tmp; }  // swap
		for(int x = 1; x < a; x++) {
			for(int y = 1; y < a; y++) {
				if(x*x + y*y == a*a) { // candidate
					int m = x * b / a;
					int n = y * b / a;
					if(m*m + n*n == b*b) { // OK
						System.out.println("YES");
						System.out.println(0 + " " + 0);
						System.out.println(-x + " " + y);
						System.out.println(-n + " " + -m);
						return;
					}
				}
			}
		}
		System.out.println("NO");

	}
	public static void main(String[] args) {
		new C().doIt();
	}

}


import java.util.*;
public class a {
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);
    int a = input.nextInt(), b = input.nextInt();
    if(a>b)
    {
        int temp = a;
        a = b; b = temp;
    }
    int[] first = py(a), second = py(b);
    if(b%a != 0 || first.length == 0 || second.length == 0)
    {
        System.out.println("NO");
    }
    else
    {
        System.out.println("YES");
        System.out.println(0+" "+0);
        System.out.println(first[0]+" "+first[1]);
        System.out.println((b/a)*first[1]+" "+(-b/a)*first[0]);
    }
}
static int[] py(int c)
{
    for(int i = 1; i<c; i++)
    {
        int diff = c*c - i*i;
        int sqrt = (int)(Math.sqrt(diff) + .5);
        if(Math.abs(sqrt - Math.sqrt(diff)) < 1e-9)
            return new int[]{i, sqrt};
    }
    return new int[0];
}
}


import java.util.*;
public class a {
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);
    int a = input.nextInt(), b = input.nextInt();
    if(a>b)
    {
        int temp = a;
        a = b; b = temp;
    }
    int[] first = py(a);
    if(b%a != 0 || first.length == 0 || first[0] == (b/a)*first[1])
    {
        System.out.println("NO");
    }
    else
    {
        System.out.println("YES");
        System.out.println(0+" "+0);
        System.out.println(first[0]+" "+first[1]);
        System.out.println((b/a)*first[1]+" "+(-b/a)*first[0]);
    }
}
static int[] py(int c)
{
    for(int i = 1; i<c; i++)
    {
        int diff = c*c - i*i;
        int sqrt = (int)(Math.sqrt(diff) + .5);
        if(Math.abs(sqrt - Math.sqrt(diff)) < 1e-9)
            return new int[]{i, sqrt};
    }
    return new int[0];
}
}


import java.util.*;
public class a {
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);
    int a = input.nextInt(), b = input.nextInt();
    int g = gcd(a, b);
    if(a>b)
    {
        int temp = a;
        a = b; b = temp;
    }
    int[] first = py(g);
    if(first.length == 0 || first[0]*(a/g) == (b/g)*first[1])
    {
        System.out.println("NO");
    }
    else
    {
        System.out.println("YES");
        System.out.println(0+" "+0);
        System.out.println(first[0]*(a/g)+" "+first[1]*(a/g));
        System.out.println((b/g)*first[1]+" "+(-b/g)*first[0]);
    }
}
static int gcd(int a, int b)
{
    if(b == 0) return a;
    return gcd(b, a%b);
}
static int[] py(int c)
{
    for(int i = 1; i<c; i++)
    {
        int diff = c*c - i*i;
        int sqrt = (int)(Math.sqrt(diff) + .5);
        if(Math.abs(sqrt - Math.sqrt(diff)) < 1e-9)
            return new int[]{i, sqrt};
    }
    return new int[0];
}
}


import java.util.*;
public class a {
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);
    int a = input.nextInt(), b = input.nextInt();
    if(a>b)
    {
        int temp = a;
        a = b; b = temp;
    }
    int[] first = py(a);
    if(b%a != 0 || first.length == 0)
    {
        System.out.println("NO");
    }
    else
    {
        System.out.println("YES");
        System.out.println(0+" "+0);
        System.out.println(first[0]+" "+first[1]);
        System.out.println((b/a)*first[1]+" "+(-b/a)*first[0]);
    }
}
static int[] py(int c)
{
    for(int i = 1; i<c; i++)
    {
        int diff = c*c - i*i;
        int sqrt = (int)(Math.sqrt(diff) + .5);
        if(Math.abs(sqrt - Math.sqrt(diff)) < 1e-6)
            return new int[]{i, sqrt};
    }
    return new int[0];
}
}


import java.util.*;
public class a {
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);
    int a = input.nextInt(), b = input.nextInt();
    if(a>b)
    {
        int temp = a;
        a = b; b = temp;
    }
    int[] first = py(a);
    if(b%a != 0 || first.length == 0 || first[1] - (b/a)*first[0] == 0)
    {
        System.out.println("NO");
    }
    else
    {
        System.out.println("YES");
        System.out.println(0+" "+0);
        System.out.println(first[0]+" "+first[1]);
        System.out.println((b/a)*first[1]+" "+(-b/a)*first[0]);
    }
}
static int[] py(int c)
{
    for(int i = 1; i<c; i++)
    {
        int diff = c*c - i*i;
        int sqrt = (int)(Math.sqrt(diff) + .5);
        if(Math.abs(sqrt - Math.sqrt(diff)) < 1e-9)
            return new int[]{i, sqrt};
    }
    return new int[0];
}
}


import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class CF239CDev2 {
	class Triangle implements Comparable<Triangle> {
		int a, b, c;

		Triangle(int a, int b, int c) {
			this.a = a;
			this.b = b;
			this.c = c;
		}

		@Override
		public int compareTo(Triangle o) {
			return c - o.c;
		}
	}

	Triangle[] getIntegerTriangle() {
		int a, a2, b, b2;
		Set<Triangle> al = new HashSet<Triangle>();

		for (a = 1; a <= 1000; a++) {
			a2 = a * a;
			for (b = a; b <= 1000; b++) {
				b2 = b * b;
				double c = Math.sqrt(a2 + b2);
				if (Math.floor(c) == c) {
					al.add(new Triangle(a, b, (int) c));
				}
			}
		}
		Triangle ts[] = al.toArray(new Triangle[0]);
		Arrays.sort(ts);
		return ts;
	}

	String solve(int l1, int l2) {
		boolean l1IsOk = false, l2IsOk = false;
		boolean allIsOk = false;
		Triangle[] ts = getIntegerTriangle();
		int ax = 0, ay = 0, bx = 0, by = 0;
		for (int i = 0; i < ts.length; i++) {
			if (ts[i].c == l1) {
				l1IsOk = true;
			}
			if (ts[i].c == l2) {
				l2IsOk = true;
			}
			if (l1IsOk && l2IsOk) {
				for (int j = 0; j < ts.length; j++) {
					if (l1 % ts[j].c == 0 && l2 % ts[j].c == 0) {
						allIsOk = true;
						int k1 = l1 / ts[j].c;
						int k2 = l2 / ts[j].c;
						ax = ts[j].a * k1;
						ay = ts[j].b * k1;
						bx = -ts[j].b * k2;
						by = ts[j].a * k2;
						if (ay == by) {
							ax = ts[j].b * k1;
							ay = ts[j].a * k1;
							bx = -ts[j].b * k2;
							by = ts[j].a * k2;
						}
						break;
					}
				}
			}
			if (allIsOk)
				break;
		}

		return !allIsOk ? "NO" : "YES\n0 0\n" + ax + " " + ay + "\n" + bx + " "
				+ by;
	}

	String solve(InputStream in) {
		Scanner sc = new Scanner(in);
		int leg1 = sc.nextInt();
		int leg2 = sc.nextInt();
		return solve(leg1, leg2);
	}

	public static void main(String[] args) {
		System.out.println(new CF239CDev2().solve(System.in));
	}
}


import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class CF239CDev2 {
	class Triangle implements Comparable<Triangle> {
		int a, b, c;

		Triangle(int a, int b, int c) {
			this.a = a;
			this.b = b;
			this.c = c;
		}

		@Override
		public int compareTo(Triangle o) {
			return c - o.c;
		}
	}

	Triangle[] getIntegerTriangle() {
		int a, a2, b, b2;
		Set<Triangle> al = new HashSet<Triangle>();

		for (a = 1; a <= 1000; a++) {
			a2 = a * a;
			for (b = a; b <= 1000; b++) {
				b2 = b * b;
				double c = Math.sqrt(a2 + b2);
				if (Math.floor(c) == c) {
					al.add(new Triangle(a, b, (int) c));
				}
			}
		}
		Triangle ts[] = al.toArray(new Triangle[0]);
		Arrays.sort(ts);
		return ts;
	}

	String solve(int l1, int l2) {
		boolean l1IsOk = false, l2IsOk = false;
		boolean allIsOk = false;
		Triangle[] ts = getIntegerTriangle();
		int ax = 0, ay = 0, bx = 0, by = 0;
		for (int i = 0; i < ts.length; i++) {
			if (ts[i].c == l1) {
				l1IsOk = true;
			}
			if (ts[i].c == l2) {
				l2IsOk = true;
			}
			if (l1IsOk && l2IsOk) {
				for (int j = 0; j < ts.length; j++) {
					if (l1 % ts[j].c == 0 && l2 % ts[j].c == 0) {
						allIsOk = true;
						int k1 = l1 / ts[j].c;
						int k2 = l2 / ts[j].c;
						ax = ts[j].a * k1;
						ay = ts[j].b * k1;
						bx = -ts[j].b * k2;
						by = ts[j].a * k2;
						if (ay == by) {
							ax = ts[j].b * k2;
							ay = ts[j].a * k2;
							bx = -ts[j].a * k1;
							by = ts[j].b * k1;
						}
						break;
					}
				}
			}
			if (allIsOk)
				break;
		}

		return !allIsOk ? "NO" : "YES\n0 0\n" + ax + " " + ay + "\n" + bx + " "
				+ by;
	}

	String solve(InputStream in) {
		Scanner sc = new Scanner(in);
		int leg1 = sc.nextInt();
		int leg2 = sc.nextInt();
		return solve(leg1, leg2);
		//		printIntegerHypotenuse();
		//		return "";
	}

	public static void main(String[] args) {
		System.out.println(new CF239CDev2().solve(System.in));
	}
}


import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class CF239CDev2 {
	class Triangle implements Comparable<Triangle> {
		int a, b, c;

		Triangle(int a, int b, int c) {
			this.a = a;
			this.b = b;
			this.c = c;
		}

		@Override
		public int compareTo(Triangle o) {
			return c - o.c;
		}
	}

	Triangle[] getIntegerTriangle() {
		int a, a2, b, b2;
		Set<Triangle> al = new HashSet<Triangle>();

		for (a = 1; a <= 1000; a++) {
			a2 = a * a;
			for (b = a; b <= 1000; b++) {
				b2 = b * b;
				double c = Math.sqrt(a2 + b2);
				if (Math.floor(c) == c) {
					al.add(new Triangle(a, b, (int) c));
				}
			}
		}
		Triangle ts[] = al.toArray(new Triangle[0]);
		Arrays.sort(ts);
		return ts;
	}

	String solve(int l1, int l2) {
		boolean l1IsOk = false, l2IsOk = false;
		boolean allIsOk = false;
		Triangle[] ts = getIntegerTriangle();
		int ax = 0, ay = 0, bx = 0, by = 0;
		for (int i = 0; i < ts.length; i++) {
			if (ts[i].c == l1) {
				l1IsOk = true;
			}
			if (ts[i].c == l2) {
				l2IsOk = true;
			}
			if (l1IsOk && l2IsOk) {
				for (int j = 0; j < ts.length; j++) {
					if (l1 % ts[j].c == 0 && l2 % ts[j].c == 0) {
						allIsOk = true;
						int k1 = l1 / ts[j].c;
						int k2 = l2 / ts[j].c;
						ax = ts[j].a * k1;
						ay = ts[j].b * k1;
						bx = -ts[j].b * k2;
						by = ts[j].a * k2;
						if (ay == by) {
							ax = ts[j].b * k1;
							ay = ts[j].a * k1;
							bx = -ts[j].a * k2;
							by = ts[j].b * k2;
						}
						break;
					}
				}
			}
			if (allIsOk)
				break;
		}

		return !allIsOk ? "NO" : "YES\n0 0\n" + ax + " " + ay + "\n" + bx + " "
				+ by;
	}

	String solve(InputStream in) {
		Scanner sc = new Scanner(in);
		int leg1 = sc.nextInt();
		int leg2 = sc.nextInt();
		return solve(leg1, leg2);
	}

	public static void main(String[] args) {
		System.out.println(new CF239CDev2().solve(System.in));
	}
}


import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class CF239CDev2 {
	class Triangle implements Comparable<Triangle> {
		int a, b, c;

		Triangle(int a, int b, int c) {
			this.a = a;
			this.b = b;
			this.c = c;
		}

		@Override
		public int compareTo(Triangle o) {
			return c - o.c;
		}
	}

	Triangle[] getIntegerTriangle() {
		int a, a2, b, b2;
		Set<Triangle> al = new HashSet<Triangle>();

		for (a = 1; a <= 1000; a++) {
			a2 = a * a;
			for (b = a; b <= 1000; b++) {
				b2 = b * b;
				double c = Math.sqrt(a2 + b2);
				if (Math.floor(c) == c) {
					al.add(new Triangle(a, b, (int) c));
				}
			}
		}
		Triangle ts[] = al.toArray(new Triangle[0]);
		Arrays.sort(ts);
		return ts;
	}

	String solve(int l1, int l2) {
		boolean l1IsOk = false, l2IsOk = false;
		boolean allIsOk = false;
		Triangle[] ts = getIntegerTriangle();
		int ax = 0, ay = 0, bx = 0, by = 0;
		for (int i = 0; i < ts.length; i++) {
			if (ts[i].c == l1) {
				l1IsOk = true;
			}
			if (ts[i].c == l2) {
				l2IsOk = true;
			}
			if (l1IsOk && l2IsOk) {
				for (int j = 0; j < ts.length; j++) {
					if (l1 % ts[j].c == 0 && l2 % ts[j].c == 0) {
						allIsOk = true;
						int k1 = l1 / ts[j].c;
						int k2 = l2 / ts[j].c;
						ax = ts[j].a * k1;
						ay = ts[j].b * k1;
						bx = -ts[j].b * k2;
						by = ts[j].a * k2;
						break;
					}
				}
			}
			if (allIsOk)
				break;
		}

		return !allIsOk ? "NO" : "YES\n0 0\n" + ax + " " + ay + "\n" + bx + " " + by;
	}

	String solve(InputStream in) {
		Scanner sc = new Scanner(in);
		int leg1 = sc.nextInt();
		int leg2 = sc.nextInt();
		return solve(leg1, leg2);
		//		printIntegerHypotenuse();
		//		return "";
	}

	public static void main(String[] args) {
		System.out.println(new CF239CDev2().solve(System.in));
	}
}


import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class CF239CDev2 {
	class Triangle implements Comparable<Triangle> {
		int a, b, c;

		Triangle(int a, int b, int c) {
			this.a = a;
			this.b = b;
			this.c = c;
		}

		@Override
		public int compareTo(Triangle o) {
			return c - o.c;
		}
	}

	Triangle[] getIntegerTriangle() {
		int a, a2, b, b2;
		Set<Triangle> al = new HashSet<Triangle>();

		for (a = 1; a <= 1000; a++) {
			a2 = a * a;
			for (b = a; b <= 1000; b++) {
				b2 = b * b;
				double c = Math.sqrt(a2 + b2);
				if (Math.floor(c) == c) {
					al.add(new Triangle(a, b, (int) c));
				}
			}
		}
		Triangle ts[] = al.toArray(new Triangle[0]);
		Arrays.sort(ts);
		return ts;
	}

	String solve(int l1, int l2) {
		boolean l1IsOk = false, l2IsOk = false;
		boolean allIsOk = false;
		Triangle[] ts = getIntegerTriangle();
		int ax = 0, ay = 0, bx = 0, by = 0;
		for (int i = 0; i < ts.length; i++) {
			if (ts[i].c == l1) {
				l1IsOk = true;
			}
			if (ts[i].c == l2) {
				l2IsOk = true;
			}
			if (l1IsOk && l2IsOk) {
				for (int j = 0; j < ts.length; j++) {
					if (l1 % ts[j].c == 0 && l2 % ts[j].c == 0) {
						allIsOk = true;
						int k1 = l1 / ts[j].c;
						int k2 = l2 / ts[j].c;
						ax = ts[j].a * k1;
						ay = ts[j].b * k1;
						bx = -ts[j].b * k2;
						by = ts[j].a * k2;
						break;
					}
				}
			}
			if (allIsOk)
				break;
		}

		return !allIsOk ? "NO" : "0 0\n" + ax + " " + ay + "\n" + bx + " " + by;
	}

	String solve(InputStream in) {
		Scanner sc = new Scanner(in);
		int leg1 = sc.nextInt();
		int leg2 = sc.nextInt();
		return solve(leg1, leg2);
		//		printIntegerHypotenuse();
		//		return "";
	}

	public static void main(String[] args) {
		System.out.println(new CF239CDev2().solve(System.in));
	}
}


import java.io.*;
import java.util.StringTokenizer;

/**
 * Created by Vadim Semenov on 30-03-2014.
 */
public class TaskC implements Runnable {
    private Output solve(Input input) {
        for (int i = 1; i <= input.b; i++) {
            for (int j = 1; j < i; j++) {
                int k = i - j;
                int aa = input.a * input.a - j * j;
                int aaa = (int) Math.sqrt(aa);
                if (aaa * aaa != aa) continue;
                int bb = input.b * input.b - i * i;
                int bbb = (int) Math.sqrt(bb);
                if (bbb * bbb != bb) continue;
                if (k * k + (aaa + bbb) * (aaa + bbb) !=
                        input.a * input.a + input.b * input.b) continue;
                Output output = new Output();
                output.x1 = 0;
                output.y1 = k;
                output.x2 = aaa;
                output.y2 = i;
                output.x3 = aaa + bbb;
                output.y3 = 0;
                return output;
            }
        }
        Output output = new Output();
        output.x1 = Integer.MIN_VALUE;
        return output;
    }

    private Input read(InputReader in) {
        Input input = new Input();
        input.a = in.nextInt();
        input.b = in.nextInt();
        input.check();
        return input;
    }

    private void write(PrintWriter out, Output output) {
        if (output.x1 == Integer.MIN_VALUE) {
            out.println("NO");
        } else {
            out.println("YES");
            out.println(output.x1 + " " + output.y1);
            out.println(output.x2 + " " + output.y2);
            out.println(output.x3 + " " + output.y3);
        }
    }

    private static class Input {
        int a, b;
        void check() {
            if (a > 1000 || b > 1000) {
                throw new RuntimeException();
            }
            if (a > b) {
                int t = a;
                a = b;
                b = t;
            }
        }
    }

    private static class Output {
        int x1, x2, x3, y1, y2, y3;
    }

    @Override
    public void run() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        File inputFile = new File("taskc.in");
        File outputFile = new File("taskc.out");
        if (inputFile.exists() && inputFile.canRead()) {
            try {
                inputStream = new FileInputStream(inputFile);
                outputStream = new FileOutputStream(outputFile);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Input input = read(in);
        Output output = solve(input);
        write(out, output);
        in.close();
        out.close();
    }

    public static void main(String[] args) {
        new TaskC().run();
    }

    public static class InputReader {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public boolean hasNext() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                String line = readLine();
                if (line == null) {
                    return false;
                }
                tokenizer = new StringTokenizer(line);
            }
            return true;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(readLine());
            }
            return tokenizer.nextToken();
        }

        public String readLine() {
            String line = null;
            try {
                line = reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return line;
        }

        public void close() {
            tokenizer = null;
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


import java.util.List;
import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author desc
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {

    class P {
        int x, y;
    }

    public void solve(int testNumber, Scanner in, PrintWriter out) {
        int ta = in.nextInt();
        int tb = in.nextInt();
        int a = Math.min(ta, tb);
        int b = Math.max(ta, tb);
        int c2 = b * b - a * a;

        List<P> pa = findPair(a);
        List<P> pb = findPair(b);
        List<P> pc = findPair2(c2);

        for (P a1 : pa) {
            for (P b1 : pb) {
                if (a1.x * b1.x == a1.y * b1.y && a1.y != b1.y) {
                    out.println("YES");
                    out.println("0 0");
                    out.println((-1 * a1.x) + " " + a1.y);
                    out.println(b1.x + " " + b1.y);
                    return;
                }
            }

            for (P b1 : pc) {
                if (a1.x * b1.x == a1.y * b1.y && a1.y != b1.y) {
                    out.println("YES");
                    out.println("0 0");
                    out.println((-1 * a1.x) + " " + a1.y);
                    out.println(b1.x + " " + b1.y);
                    return;
                }
            }

        }

        out.print("NO");
    }

    List<P> findPair(int c){
        List<P> ps = new ArrayList<>();
        for (int i = 1; i < 1001 && i < c; i++) {
            for (int j = 1; j < 1001 && i * i + j * j <= c * c; j++) {
                if (i * i + j * j == c * c) {
                    P p = new P();
                    p.x = i;
                    p.y = j;
                    ps.add(p);
                }
            }
        }
        return ps;
    }

    List<P> findPair2(int c2){
        List<P> ps = new ArrayList<>();
        for (int i = 1; i < 1001; i++) {
            for (int j = 1; j < 1001 && i * i + j * j <= c2; j++) {
                if (i * i + j * j == c2) {
                    P p = new P();
                    p.x = i;
                    p.y = j;
                    ps.add(p);
                }
            }
        }
        return ps;
    }
}


import java.util.List;
import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author desc
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {

    class P {
        int x, y;
    }

    public void solve(int testNumber, Scanner in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();

        List<P> pa = findPair(a);
        List<P> pb = findPair(b);

        for (P a1 : pa) {
            for (P b1 : pb) {
                if (a1.x != b1.x && a1.y != b1.y) {
                    out.println("YES");
                    out.println("0 0");
                    out.println(a1.x + " " + a1.y);
                    out.println(b1.x + " " + b1.y);
                    return;
                }

                if (a1.x * b1.y != b1.x * a1.y) {

                    out.println("YES");
                    out.println("0 0");
                    out.println(a1.x + " " + a1.y);
                    out.println((a1.x + b1.x) + " " + (a1.y + b1.y));
                    return;
                }
            }
        }

        out.print("NO");
    }

    List<P> findPair(int c){
        List<P> ps = new ArrayList<>();
        for (int i = 1; i < 1001 && i < c; i++) {
            for (int j = 1; j < 1001 && i * i + j * j <= c * c; j++) {
                if (i * i + j * j == c * c) {
                    P p = new P();
                    p.x = i;
                    p.y = j;
                    ps.add(p);
                }
            }
        }
        return ps;
    }
}


import java.util.List;
import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author desc
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {

    class P {
        int x, y;
    }

    public void solve(int testNumber, Scanner in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();

        List<P> pa = findPair(a);
        List<P> pb = findPair(b);

        for (P a1 : pa) {
            for (P b1 : pb) {
                if (a1.x != b1.x && a1.y != b1.y) {
                    out.println("YES");
                    out.println("0 0");
                    out.println(a1.x + " " + a1.y);
                    out.println(b1.x + " " + b1.y);
                    return;
                }
            }
        }

        out.print("NO");
    }

    List<P> findPair(int c){
        List<P> ps = new ArrayList<>();
        for (int i = 1; i < 1001 && i < c; i++) {
            for (int j = 1; j < 1001 && i * i + j * j <= c * c; j++) {
                if (i * i + j * j == c * c) {
                    P p = new P();
                    p.x = i;
                    p.y = j;
                    ps.add(p);
                }
            }
        }
        return ps;
    }
}


import java.util.*;
import java.awt.Point;
import java.io.*;
import java.math.BigInteger;

public class C1
{
    FastScanner in;
    PrintWriter out;

    public int gcd(int a, int b)
    {
        while (b !=0)
        {
            int tmp = a % b;
            a = b;
            b = tmp;
        }

        return a;

    }

    public void solve() throws IOException
    {
        int a = in.nextInt();
        int b = in.nextInt();

        int a2     = a * a;
        int bFound = 0;

        for(int x = 1; x < a; x++)
        {
            double y = Math.sqrt(a2 - x * x);
            int    yf = (int)y;

            if(y == yf)
            {
                int g  = gcd(x, yf);
                int bx = (int)(-y / g);
                int by = (int)(x / g);

                double bLen  = Math.sqrt(bx * bx + by * by);
                int    bLenF = (int)bLen;

                if(bLen == bLenF && b % bLenF == 0)
                {
                    int bxFound = (int)(-y / g * b / bLenF);
                    int byFound = (int)(x / g * b / bLenF);

                    int cx = x - bxFound;
                    int cy = yf - byFound;

                    if(cx != 0 && cy != 0)
                    {
                        bFound = 1;
                        out.println("YES");
                        out.println("" + 0 + " " + 0);
                        out.println("" + x + " " + yf);
                        out.println("" + bxFound + " " + byFound);
                        break;
                    }
                }
            }
        }

        if(bFound == 0)
        {
            out.print("NO");
        }

    }

    public void run() {
        try {
            //in  = new FastScanner(new File("sum.in"));
            //out = new PrintWriter(new File("sum.out"));

            in  = new FastScanner();
            out = new PrintWriter(System.out);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner() {

            br = new BufferedReader(new InputStreamReader(System.in));

        }

        FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int size)
        {
            int[] array = new int[size];

            for (int i = 0; i < size; i++){
                array[i] = nextInt();
            }

            return array;
        }

        long[] nextLongArray(int size)
        {
            long[] array = new long[size];

            for (int i = 0; i < size; i++){
                array[i] = nextLong();
            }

            return array;
        }

        BigInteger nextBigInteger()
        {
            return new BigInteger(next());
        }

        Point nextIntPoint()
        {
            int x = nextInt();
            int y = nextInt();
            return new Point(x, y);
        }

        Point[] nextIntPointArray(int size)
        {
            Point[] array = new Point[size];

            for (int index = 0; index < size; ++index){
                array[index] = nextIntPoint();
            }

            return array;
        }

        List<Integer>[] readGraph(int vertexNumber, int edgeNumber, boolean undirected)
        {
            List<Integer>[] graph = new List[vertexNumber];

            for (int index = 0; index < vertexNumber; ++index)
            {
                graph[index] = new ArrayList<Integer>();
            }

            while (edgeNumber-- > 0)
            {
                int from = nextInt() - 1;
                int to   = nextInt() - 1;

                graph[from].add(to);
                if(undirected)
                    graph[to].add(from);
            }

            return graph;
        }
    }

    public static void main(String[] arg)
    {
        new C1().run();
    }
}


import java.util.*;
import java.awt.Point;
import java.io.*;
import java.math.BigInteger;

public class C1
{
    FastScanner in;
    PrintWriter out;

    public int gcd(int a, int b)
    {
        while (b !=0)
        {
            int tmp = a % b;
            a = b;
            b = tmp;
        }

        return a;

    }

    public void solve() throws IOException
    {
        int a = in.nextInt();
        int b = in.nextInt();

        int a2     = a * a;
        int bFound = 0;

        for(int x = 1; x < a; x++)
        {
            double y = Math.sqrt(a2 - x * x);
            int    yf = (int)y;

            if(y == yf)
            {
                int g  = gcd(x, yf);
                int bx = (int)(-y / g);
                int by = (int)(x / g);

                double bLen  = Math.sqrt(bx * bx + by * by);
                int    bLenF = (int)bLen;

                if(bLen == bLenF && b % bLenF == 0)
                {
                    int bxFound = (int)(-y / g * b / bLenF);
                    int byFound = (int)(x / g * b / bLenF);

                    int cx = x - bxFound;
                    int cy = yf - byFound;

                    if(cx != 0 && cy != 0)
                    {
                        bFound = 1;
                        out.println("YES");
                        out.println("" + 0 + " " + 0);
                        out.println("" + bxFound + " " + byFound);
                        out.println("" + cx + " " + cy);
                        break;
                    }
                }
            }
        }

        if(bFound == 0)
        {
            out.print("NO");
        }

    }

    public void run() {
        try {
            //in  = new FastScanner(new File("sum.in"));
            //out = new PrintWriter(new File("sum.out"));

            in  = new FastScanner();
            out = new PrintWriter(System.out);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner() {

            br = new BufferedReader(new InputStreamReader(System.in));

        }

        FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int size)
        {
            int[] array = new int[size];

            for (int i = 0; i < size; i++){
                array[i] = nextInt();
            }

            return array;
        }

        long[] nextLongArray(int size)
        {
            long[] array = new long[size];

            for (int i = 0; i < size; i++){
                array[i] = nextLong();
            }

            return array;
        }

        BigInteger nextBigInteger()
        {
            return new BigInteger(next());
        }

        Point nextIntPoint()
        {
            int x = nextInt();
            int y = nextInt();
            return new Point(x, y);
        }

        Point[] nextIntPointArray(int size)
        {
            Point[] array = new Point[size];

            for (int index = 0; index < size; ++index){
                array[index] = nextIntPoint();
            }

            return array;
        }

        List<Integer>[] readGraph(int vertexNumber, int edgeNumber, boolean undirected)
        {
            List<Integer>[] graph = new List[vertexNumber];

            for (int index = 0; index < vertexNumber; ++index)
            {
                graph[index] = new ArrayList<Integer>();
            }

            while (edgeNumber-- > 0)
            {
                int from = nextInt() - 1;
                int to   = nextInt() - 1;

                graph[from].add(to);
                if(undirected)
                    graph[to].add(from);
            }

            return graph;
        }
    }

    public static void main(String[] arg)
    {
        new C1().run();
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Triangle {

	static class Point {
		long x, y;

		Point(long x, long y) {
			this.x = x;
			this.y = y;
		}

		public long sqDist(Point o) {
			long xDiff = Math.abs(this.x - o.x);
			long yDiff = Math.abs(this.y - o.y);
			return xDiff * xDiff + yDiff * yDiff;
		}

		public boolean diff(Point o) {
			return this.x != o.x && this.y != o.y;
		}

		public void change(int type) {
			this.x = Math.abs(this.x);
			this.y = Math.abs(this.y);
			if (type == 1) {
				this.x *= -1;
			} else if (type == 2) {
				this.x *= -1;
				this.y *= -1;
			} else if (type == 3) {
				this.y *= -1;
			}
		}
	}

	static boolean isPerfect(long x) {
		long y = (long) Math.sqrt(x);
		return y * y == x;
	}

	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		sc = new StringTokenizer("");
		int a = nxtInt();
		int b = nxtInt();
		long c2 = a * a + b * b;
		boolean done = false;
		for (long x1 = 1; x1 < a && !done; x1++) {
			long y1 = a * a - x1 * x1;
			if (isPerfect(y1)) {
				y1 = (long) Math.sqrt(y1);
				Point one = new Point(x1, y1);
				for (long x2 = 1; x2 < b && !done; x2++) {
					long y2 = b * b - x2 * x2;
					if (isPerfect(y2)) {
						y2 = (long) Math.sqrt(y2);
						Point two = new Point(x2, y2);
						for (int type = 0; type < 4 && !done; type++) {
							one.change(type);
							two.change((type + 1) % 4);
							if (one.diff(two) && one.sqDist(two) == c2) {
								done = true;
								out.println("YES");
								out.println("0 0");
								out.println(one.x + " " + one.y);
								out.println(two.x + " " + two.y);
							}
						}
					}
				}
			}
		}
		if (!done)
			out.println("NO");
		br.close();
		out.close();
	}

	static BufferedReader br;
	static StringTokenizer sc;
	static PrintWriter out;

	static String nxtTok() throws IOException {
		while (!sc.hasMoreTokens()) {
			String s = br.readLine();
			if (s == null)
				return null;
			sc = new StringTokenizer(s.trim());
		}
		return sc.nextToken();
	}

	static int nxtInt() throws IOException {
		return Integer.parseInt(nxtTok());
	}

	static long nxtLng() throws IOException {
		return Long.parseLong(nxtTok());
	}

	static double nxtDbl() throws IOException {
		return Double.parseDouble(nxtTok());
	}

	static int[] nxtIntArr(int n) throws IOException {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nxtInt();
		return a;
	}

	static long[] nxtLngArr(int n) throws IOException {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nxtLng();
		return a;
	}

	static char[] nxtCharArr() throws IOException {
		return nxtTok().toCharArray();
	}
}


import java.io.*;
import java.util.*;

public class C {
    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;
    int b;
    final double eps = 0.00001;
    final double pi = 3.141592653;

    public String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public static void main(String[] args) throws IOException {
        new C().run();
    }

    long[] check(int x, int y) {
        double phi = Math.atan2((double)y, (double)x);
        double newphi1 = phi + pi / 2;
        double newphi2 = phi - pi / 2;
        double newmod = (double)b;
        double x1 = newmod * Math.cos(newphi1);
        double y1 = newmod * Math.sin(newphi1);
        if (Math.abs(x1 - Math.round(x1)) < eps && Math.abs(y1 - Math.round(y1)) < eps) {
            long[] res = new long[2];
            res[0] = Math.round(x1);
            res[1] = Math.round(y1);
            return res;
        } else {
            double x2 = newmod * Math.cos(newphi1);
            double y2 = newmod * Math.sin(newphi1);
            if (Math.abs(x2 - Math.round(x2)) < eps && Math.abs(y2 - Math.round(y2)) < eps) {
                long[] res = new long[2];
                res[0] = Math.round(x1);
                res[1] = Math.round(y1);
                return res;
            } else {
                long[] res = new long[2];
                res[0] = Long.MAX_VALUE;
                return res;
            }
        }
    }

    public void solve() throws IOException {
        int a = nextInt();
        b = nextInt();
        for (int i = -a; i < a + 1; i++) {
            for (int j = -a; j < a + 1; j++) {
                if (i != 0 && j != 0 && i * i + j * j == a * a) {
                    long[] res = check(i, j);
                    if (res[0] != Long.MAX_VALUE) {
                        if (i != 0 && res[0] != i && res[0] != 0 && j != 0 && res[1] != j && res[1] != 0)        {
                            out.println("YES");
                            out.println(0 + " " + 0);
                            out.println(i + " " + j);
                            out.println(res[0] + " " + res[1]);
                            out.flush();
                            System.exit(0);
                        }
                    }
                }
            }
        }
        out.println("NO");
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}


import java.io.*;
import java.util.*;

public class C {
    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;
    int b;
    final double eps = 0.00001;
    final double pi = 3.141592653;

    public String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public static void main(String[] args) throws IOException {
        new C().run();
    }

    long[] check(int x, int y) {
        double phi = Math.atan2((double)y, (double)x);
        double newphi1 = phi + pi / 2;
        double newphi2 = phi - pi / 2;
        double newmod = (double)b;
        double x1 = newmod * Math.cos(newphi1);
        double y1 = newmod * Math.sin(newphi1);
        if (Math.abs(x1 - Math.round(x1)) < eps && Math.abs(y1 - Math.round(y1)) < eps) {
            long[] res = new long[2];
            res[0] = Math.round(x1);
            res[1] = Math.round(y1);
            return res;
        } else {
            double x2 = newmod * Math.cos(newphi1);
            double y2 = newmod * Math.sin(newphi1);
            if (Math.abs(x2 - Math.round(x2)) < eps && Math.abs(y2 - Math.round(y2)) < eps) {
                long[] res = new long[2];
                res[0] = Math.round(x1);
                res[1] = Math.round(y1);
                return res;
            } else {
                long[] res = new long[2];
                res[0] = Long.MAX_VALUE;
                return res;
            }
        }
    }

    public void solve() throws IOException {
        int a = nextInt();
        b = nextInt();
        for (int i = -a; i < a + 1; i++) {
            for (int j = -a; j < a + 1; j++) {
                if (i != 0 && j != 0 && i * i + j * j == a * a) {
                    long[] res = check(i, j);
                    if (res[0] != Long.MAX_VALUE) {
                        out.println("YES");
                        out.println(0 + " " + 0);
                        out.println(i + " " + j);
                        out.println(res[0] + " " + res[1]);
                        out.flush();
                        System.exit(0);
                    }
                }
            }
        }
        out.println("NO");
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}


import java.io.*;
import java.util.*;

public class C {
    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;
    int b;
    final double eps = 0.0000001;
    final double pi = 3.141592653;

    public String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public static void main(String[] args) throws IOException {
        new C().run();
    }

    long[] check(int x, int y) {
        double phi = Math.atan2((double)y, (double)x);
        double newphi1 = phi + pi / 2;
        double newphi2 = phi - pi / 2;
        double newmod = (double)b;
        double x1 = newmod * Math.cos(newphi1);
        double y1 = newmod * Math.sin(newphi1);
        if (Math.abs(x1 - Math.round(x1)) < eps && Math.abs(y1 - Math.round(y1)) < eps) {
            long[] res = new long[2];
            res[0] = Math.round(x1);
            res[1] = Math.round(y1);
            return res;
        } else {
            double x2 = newmod * Math.cos(newphi1);
            double y2 = newmod * Math.sin(newphi1);
            if (Math.abs(x2 - Math.round(x2)) < eps && Math.abs(y2 - Math.round(y2)) < eps) {
                long[] res = new long[2];
                res[0] = Math.round(x1);
                res[1] = Math.round(y1);
                return res;
            } else {
                long[] res = new long[2];
                res[0] = Long.MAX_VALUE;
                return res;
            }
        }
    }

    public void solve() throws IOException {
        int a = nextInt();
        b = nextInt();
        for (int i = -a; i < a + 1; i++) {
            for (int j = -a; j < a + 1; j++) {
                if (i != 0 && j != 0 && i * i + j * j == a * a) {
                    long[] res = check(i, j);
                    if (res[0] != Long.MAX_VALUE) {
                        out.println("YES");
                        out.println(0 + " " + 0);
                        out.println(i + " " + j);
                        out.println(res[0] + " " + res[1]);
                        out.flush();
                        System.exit(0);
                    }
                }
            }
        }
        out.println("NO");
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}


import java.util.*;

public class C {

    Scanner in = new Scanner(System.in);

    void run() {
        int a = in.nextInt();
        int b = in.nextInt();

        int b2 = b * b;
        for (int x = b - 1; x > 0; x--) {
            int x2 = x * x;
            if (x2 >= b2) {
                break;
            }
            int y = (int) (Math.round(Math.sqrt(b2 - x2)) + 0.1);
            if (y * y + x2 != b2) {
                continue;
            }
            int ys = (int) (Math.round(a * x / (double) b) + 0.1);
            int xs = (int) (Math.round(a * y / (double) b) + 0.1);
            if (xs * xs + ys * ys != a * a) {
                continue;
            }
            int dx = x + xs;
            int dy = y - ys;
            if (dy == 0 || dx == 0 || x == 0 || y == 0 || xs == 0 || ys == 0) {
                continue;
            }
            if (dx * dx + dy * dy == a * a + b2) {
                System.out.println("YES");
                System.out.println("0 0");
                System.out.println(x + " " + y);
                System.out.println((-xs) + " " + ys);
                return;
            }
        }
        System.out.println("NO");
    }

    public static void main(String... args) {
        new C().run();
    }

}


import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.Scanner;

public class C239 {

	public class solution {
		int x1;
		int y1;
		int x2;
		int y2;
		int x3;
		int y3;

		public solution() {
			x1 = x2 = y1 = y2 = x3 = y3 = 0;
		}

	}

	static boolean perfect(int num) {

		double s = Math.sqrt(num);
		int ss = (int) s;
		if (ss * ss == num)
			return true;
		else
			return false;

	}

	public void run() {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();

		ArrayList<Integer> x = new ArrayList<Integer>();
		ArrayList<Integer> y = new ArrayList<Integer>();

		for (int xx = 0 - a-a; xx <= a+a; xx++) {

			int inter = a * a - xx * xx;

			if (!perfect(inter) || xx == 0)
				continue;

			int sq = (int) Math.sqrt(inter);

			int y1 = sq;
			int y2 = -sq;

			if (y1 != 0) {
				x.add(xx);
				y.add(y1);
			}

			if (y2 != 0) {
				x.add(xx);
				y.add(y2);
			}

		}

		ArrayList<solution> all = new ArrayList<solution>();
		for (int i = 0; i < x.size(); i++) {
			int xnow = x.get(i);
			int ynow = y.get(i);

			for (int xx = xnow - b-b; xx <= xnow + b+b; xx++) {

				int inter = b * b - (xnow - xx) * (xnow - xx);

				if (!perfect(inter))
					continue;

				int sq = (int) Math.sqrt(inter);

				int yy1 = ynow - sq;

				if ((yy1 - ynow) * ynow == -xnow * (xx - xnow)) {
					solution newsol = new solution();
					newsol.x1 = 0;
					newsol.y1 = 0;
					newsol.x2 = xnow;
					newsol.y2 = ynow;
					newsol.x3 = xx;
					newsol.y3 = yy1;

					all.add(newsol);

				}
				int yy2 = sq + ynow;
				if ((yy2 - ynow) * ynow == -xnow * (xx - xnow)) {
					solution newsol = new solution();
					newsol.x1 = 0;
					newsol.y1 = 0;
					newsol.x2 = xnow;
					newsol.y2 = ynow;
					newsol.x3 = xx;
					newsol.y3 = yy2;

					all.add(newsol);

				}

			}

		}

		if (all.size() == 0)
			System.out.println("NO");
		else {

			System.out.println("YES");
			solution here = all.get(0);
			System.out.println(here.x1 + " " + here.y1);
			System.out.println(here.x2 + " " + here.y2);
			System.out.println(here.x3 + " " + here.y3);

		}

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new C239().run();

	}

}