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

public class p1294c {
	static class Pair
	{
		public int a,b;
		public Pair(int a , int b)
		{
			this.a=a; this.b=b;
		}
		public int get(int ix)
		{
			if(ix==0)
				return a;
			else
				return b;
		}
	}
	public static PrintWriter out;
	public static InputReader in;
	// taken from https://www.geeksforgeeks.org/print-all-prime-factors-of-a-given-number/
	public static ArrayList<Pair> list;
	public static void primeFactors(int n)
    {
        // Print the number of 2s that divide n
        int val = 0;
        while (n%2==0)
        {
        	val++;
            // System.out.print(2 + " ");
            n /= 2;
        }
        if(val!=0){
        	// out.println("adding "+2);
        	list.add(new Pair(2,val));
        }
        // n must be odd at this point.  So we can
        // skip one element (Note i = i +2)
        for (int i = 3; i <= Math.sqrt(n); i+= 2)
        {
        	val = 0;
            // While i divides n, print i and divide n
            while (n%i == 0)
            {
            	val++;
                // System.out.print(i + " ");
                n /= i;
            }
            if(val!=0){
            	// out.println("adding "+i);
            	list.add(new Pair(i,val));
            }
        }

        // This condition is to handle the case whien
        // n is a prime number greater than 2
        if (n > 2){
            // out.println("adding"+n);
            list.add(new Pair(n,1));
        }
    }
	public static void main(String[] args)throws IOException {
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);

		int t = in.nextInt();
		long n;
		for(int i=0;i<t;i++)
		{

			n=in.nextLong();
			// out.println("i="+i+" n="+n);
			list = new ArrayList<Pair>();
			primeFactors((int)n);
			if(list.size()>=3)
			{
				// out.println("list size"+list.size());
				out.println("YES");
				Pair p1,p2,p3;
				p1 = list.get(0);
				p2 = list.get(1);
				p3 = list.get(2);
				long val = n/(p1.a*p2.a*p3.a);
				out.println(p1.a+" "+p2.a+" "+(p3.a*(val)));
				continue;
			}
			else if(list.size()==1 && ((list.get(0)).get(1))>=6)
			{
				out.println("YES");
				long p1,p2,p3;
				p1 = (long)(list.get(0)).get(0);
				p2 = p1*p1;
				p3 = p1*p1*p1;
				long val = n/(long)(p1*p2*p3);
				out.println(p1+" "+p2+" "+(p3*val));
			}
			else if(list.size()==2)
			{
				Pair p1,p2;
				p1 = list.get(0);
				p2 = list.get(1);
				if((p1.get(1)+p2.get(1))>=4)
				{
					out.println("YES");
					long v1 = (long)p1.get(0);
					long v2 = (long)p2.get(0);
					long v3 = v1*v2;
					long val = n/(long)(v1*v2*v3);
					out.print(v1+" "+v2+" ");
					out.println(v3*val);
				}
				else
				{
					out.println("NO");
				}
			}
			else
			{
				out.println("NO");
			}
		}
		out.close();
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

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


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

public class p1294c {
	static class Pair
	{
		public int a,b;
		public Pair(int a , int b)
		{
			this.a=a; this.b=b;
		}
		public int get(int ix)
		{
			if(ix==0)
				return a;
			else
				return b;
		}
	}
	public static PrintWriter out;
	public static InputReader in;
	// taken from https://www.geeksforgeeks.org/print-all-prime-factors-of-a-given-number/
	public static ArrayList<Pair> list;
	public static void primeFactors(int n)
    {
        // Print the number of 2s that divide n
        int val = 0;
        while (n%2==0)
        {
        	val++;
            // System.out.print(2 + " ");
            n /= 2;
        }
        if(val!=0){
        	// out.println("adding "+2);
        	list.add(new Pair(2,val));
        }
        // n must be odd at this point.  So we can
        // skip one element (Note i = i +2)
        for (int i = 3; i <= Math.sqrt(n); i+= 2)
        {
        	val = 0;
            // While i divides n, print i and divide n
            while (n%i == 0)
            {
            	val++;
                // System.out.print(i + " ");
                n /= i;
            }
            if(val!=0){
            	// out.println("adding "+i);
            	list.add(new Pair(i,val));
            }
        }

        // This condition is to handle the case whien
        // n is a prime number greater than 2
        if (n > 2){
            // out.println("adding"+n);
            list.add(new Pair(n,1));
        }
    }
	public static void main(String[] args)throws IOException {
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);

		int t = in.nextInt();
		int n;
		for(int i=0;i<t;i++)
		{

			n=in.nextInt();
			// out.println("i="+i+" n="+n);
			list = new ArrayList<Pair>();
			primeFactors(n);
			if(list.size()>=3)
			{
				// out.println("list size"+list.size());
				out.println("YES");
				Pair p1,p2,p3;
				p1 = list.get(0);
				p2 = list.get(1);
				p3 = list.get(2);
				out.println(p1.a+" "+p2.a+" "+p3.a);
				continue;
			}
			else if(list.size()==1 && ((list.get(0)).get(1))>=6)
			{
				out.println("YES");
				long p1,p2,p3;
				p1 = (long)(list.get(0)).get(0);
				p2 = p1*p1;
				p3 = p1*p1*p1;
				out.println(p1+" "+p2+" "+p3);
			}
			else if(list.size()==2)
			{
				Pair p1,p2;
				p1 = list.get(0);
				p2 = list.get(1);
				if((p1.get(1)+p2.get(1))>=3)
				{
					out.println("YES");
					long v1 = (long)p1.get(0);
					long v2 = (long)p2.get(0);
					out.print(v1+" "+v2+" ");
					out.println(v1*v2);
				}
				else
				{
					out.println("NO");
				}
			}
			else
			{
				out.println("NO");
			}
		}
		out.close();
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

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


import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args) {
	   Scanner s=new Scanner(System.in);
	   int test=s.nextInt();
	       while(test>0) {
	            long n=s.nextLong();
	            long a=0,b=0,c=0;
                for (int i=2; i<=Math.sqrt(n); i++)
                {
                        if (n%i == 0)
                        {
                            a=i;
                            for (int j=2; j<=Math.sqrt(n/i); j++)
                            {
                                if((n/a)%j==0&&i!=j){
                                    b=j;
                                    long num=(n/(a*b));
                                    for (int k=2; k<=num; k++)
                                    {
                                        if((num)%k==0&&(j!=k&&i!=k)){
                                            c=k;
                                            break;
                                        }
                                    }
                                    if(c!=0)
                                        break;
                                }
                            }
                            if(c!=0)
                                break;
                        }
                    }
                    if(c==0){
                        System.out.println("NO");
                    }else{
                        System.out.println("YES");
                        System.out.println(a+" "+b+" "+c);
                    }

	            test--;
	       }
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args) {
	   Scanner s=new Scanner(System.in);
	   int test=s.nextInt();
	       while(test>0) {
	            long n=s.nextLong();
	            int a=0,b=0,c=0;
	            for(int i=2;i*i<=n;i++){
	                if(n%i==0){
	                    a=i;
	                    break;
	                }
	            }
	            if(a!=0){
	                for(int i=2;(i<=(n/a));i++){
	                   if((n/a)%i==0&&i!=a){
	                      b=i;
	                      break;
	                   }
	            }
	           // System.out.println(a);
	           // System.out.println(b);
	            }if(a!=0&&b!=0){
	                for(int i=2;(i<=((n/a)/b));i++){
	                   if(((n/a)/b)%i==0&&(i!=a&&i!=b)){
	                      c=i;
	                      break;
	                   }
	             }
	            }

	            if(c==0){
	                System.out.println("NO");
	            }else{
	                System.out.println("YES");
	                System.out.println(a+" "+b+" "+c);
	            }

	            test--;
	       }
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args) {
	   Scanner s=new Scanner(System.in);
	   int test=s.nextInt();
	       while(test>0) {
	            long n=s.nextLong();
	            int a=0,b=0,c=0,kk=0;
	            for(int j=2;j*j<=n&&c==0;j++)
	            {
	                if(n%j==0)
	                {
	                           a=j;
	                        for(int ii=2;(ii<=(n/a));ii++)
	                        {
	                            if((n/a)%ii==0&&ii!=a)
	                            {
	                                       b=ii;
	                                    for(int i=2;(i<=((n/a)/b));i++){
	                                       if(((n/a)/b)%i==0&&(i!=a&&i!=b)){
	                                          c=i;
	                                          break;
	                                       }
	                                     }
	                                if(c==0){
	                                }else{
	                                    System.out.println("YES");
	                                    System.out.println(a+" "+b+" "+c);
	                                    kk=1;
	                                    break;
	                                }
	                            }
	                        }
	                }
	            }
	            if(kk==0){
	                 System.out.println("NO");
	            }
	            test--;
	       }
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args) {
	   Scanner s=new Scanner(System.in);
	   int test=s.nextInt();
	       while(test>0) {
	            long n=s.nextLong();
	            long a=0,b=0,c=0;
                for (int i=2; i<=Math.sqrt(n); i++)
                {
                        if (n%i == 0)
                        {
                            a=i;
                            for (int j=2; j<=Math.sqrt(n/a); j++)
                            {
                                if((n/a)%j==0&&i!=j){
                                    b=j;
                                    if((n/(a*b))!=a&&(n/(a*b))!=b){
                                        c=(n/(a*b));
                                    }
                                    if(c!=0)
                                        break;
                                }
                            }
                            if(c!=0)
                                break;
                        }
                    }
                    if(c==0){
                        System.out.println("NO");
                    }else{
                        System.out.println("YES");
                        System.out.println(a+" "+b+" "+c);
                    }

	            test--;
	       }
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args) {
	   Scanner s=new Scanner(System.in);
	   int test=s.nextInt();
	       while(test>0) {
	            long n=s.nextLong();
	            int a=0,b=0,c=0;
	            for(int i=2;i*i<=n;i++){
	                if(n%i==0){
	                    a=i;
	                    break;
	                }
	            }
	            if(a!=0){
	                for(int i=2;(i*i<=(n/a));i++){
	                   if((n/a)%i==0&&i!=a){
	                      b=i;
	                      break;
	                   }
	            }
	           // System.out.println(a);
	           // System.out.println(b);
	            }if(a!=0&&b!=0){
	                for(int i=2;(i<=((n/a)/b));i++){
	                   if(((n/a)/b)%i==0&&(i!=a&&i!=b)){
	                      c=i;
	                      break;
	                   }
	             }
	            }

	            if(c==0){
	                System.out.println("NO");
	            }else{
	                System.out.println("YES");
	                System.out.println(a+" "+b+" "+c);
	            }

	            test--;
	       }
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args) {
	   Scanner s=new Scanner(System.in);
	   int test=s.nextInt();
	       while(test>0) {
	            long n=s.nextLong();
	            int a=0,b=0,c=0,kk=0;
	            for(int j=2;j*j<=n&&c==0;j++)
	            {
	                if(n%j==0)
	                {
	                           a=j;
	                        for(int ii=2;(ii*ii<=(n/a));ii++)
	                        {
	                            if((n/a)%ii==0&&ii!=a)
	                            {
	                                       b=ii;
	                                    for(int i=2;(i<=((n/a)/b));i++){
	                                       if(((n/a)/b)%i==0&&(i!=a&&i!=b)){
	                                          c=i;
	                                          break;
	                                       }
	                                     }
	                                if(c==0){
	                                }else{
	                                    System.out.println("YES");
	                                    System.out.println(a+" "+b+" "+c);
	                                    kk=1;
	                                    break;
	                                }
	                            }
	                        }
	                }
	            }
	            if(kk==0){
	                 System.out.println("NO");
	            }
	            test--;
	       }
	}
}


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Numbers {
	public static void main(String[] args) {
		int tc;
		int n;
		Scanner input = new Scanner(System.in);
		tc = input.nextInt();
		for(int i=0; i<tc; i++) {
			long c = 1;
			List<Integer> list = new ArrayList<Integer>();
			n = input.nextInt();
			for(int j=2; j<=n; j++) {
				if(n % j == 0) {
					n = n/j;
					list.add(j);
				}
			}
			if(list.size()>=3) {
				System.out.println("YES");
				System.out.print(list.get(0)+" "+list.get(1)+" ");
				for(int k = 2; k<list.size(); k++) {
					c *= list.get(k);
				}
				System.out.print(c);
				System.out.println();

			} else {
				System.out.println("NO");
			}
		}
	}
}


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Numbers {
	public static void main(String[] args) {

		int tc;
		int n;
		Scanner input = new Scanner(System.in);
		tc = input.nextInt();
		for(int i=0; i<tc; i++) {
			long c = 0;
			List<Integer> list = new ArrayList<Integer>();
			n = input.nextInt();
			//long start = System.currentTimeMillis();
			for(int j=2; j<=Math.sqrt(n); j++) {
				if(n % j == 0) {
					c++;
					if(c==3)
						break;
					list.add(j);
				}
			}
			if(c==3) {
				System.out.println("YES");
				System.out.print(list.get(0)+" "+list.get(1)+" ");
				System.out.print(n/(list.get(0) * list.get(1)));
			} else {
				System.out.println("NO");
			}

			//long end = System.currentTimeMillis();

		    //System.out.println((end - start) + " ms");
		}

	}
}


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Numbers {
	public static void main(String[] args) {
		int tc;
		int n;
		Scanner input = new Scanner(System.in);
		tc = input.nextInt();
		for(int i=0; i<tc; i++) {
			long c = 0;
			List<Integer> list = new ArrayList<Integer>();
			n = input.nextInt();
			for(int j=2; j<=n; j++) {
				if(n % j == 0) {
					c++;
					if(c == 3) {
						list.add(n);
						break;
					}
					n = n/j;
					list.add(j);
				}
			}
			if(list.size()>=3) {
				System.out.println("YES");
				System.out.println(list.get(0)+" "+list.get(1)+" "+list.get(2));

			} else {
				System.out.println("NO");
			}
		}
	}
}


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Numbers {
	public static void main(String[] args) {

		int tc;
		int n;
		Scanner input = new Scanner(System.in);
		tc = input.nextInt();
		for(int i=0; i<tc; i++) {
			long c = 0;
			List<Integer> list = new ArrayList<Integer>();
			n = input.nextInt();
			//long start = System.currentTimeMillis();
			for(int j=2; j<=Math.sqrt(n); j++) {
				if(n % j == 0) {
					c++;
					if(c==3)
						break;
					list.add(j);
				}
			}
			if(c==3) {
				System.out.println("YES");
				System.out.print(list.get(0)+" "+list.get(1)+" ");
				System.out.println(n/(list.get(0) * list.get(1)));
			} else {
				System.out.println("NO");
			}

			//long end = System.currentTimeMillis();

		    //System.out.println((end - start) + " ms");
		}

	}
}


import java.util.Scanner;

public class Numbers {
	public static void main(String[] args) {

		int tc;
		int n;
		int prev=-1;
		int flag=0;
		Scanner input = new Scanner(System.in);
		tc = input.nextInt();
		for(int i=0; i<tc; i++) {
			prev=-1;
			flag=0;
			n = input.nextInt();
			//long start = System.currentTimeMillis();
			for(int j=2; j<=Math.sqrt(n); j++) {

				if(n%j == 0)
				{
					if(prev == -1)
					{
						prev = j;
					}
					else
					{
						if(n == prev*j*(n/(prev*j)) && (n/(prev*j)) != prev && (n/(prev*j)) != j)
						{
							long res = n/(prev*j);
							System.out.println("YES");
							System.out.println(prev + " " + j + " " + res);
							flag=1;
							break;
						}
					}
				}
			}
			if(flag == 0)
				System.out.println("NO");

			//long end = System.currentTimeMillis();

		    //System.out.println((end - start) + " ms");
		}

	}
}


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

import javax.lang.model.util.ElementScanner6;

import java.lang.*;
import java.io.*;

public class Solution
{
    public static void main(String args[])throws IOException
    {/*
        InputStreamReader isr=new InputStreamReader(System.in);
        BufferedReader br=new BufferedReader(isr);
        int a=Integer.parseInt(br.readLine());*/
        FastReader in=new FastReader(System.in);
        long n,d,d2,a,b,c;
        long i,j,k=0;

        int t=in.nextInt();
        for(i=0;i<t;i++)
        {
            n=in.nextLong();
            d=n;
            d2=(long)Math.sqrt(n)+1;
            int fg=0;
            a=0;
            b=0;
            c=0;
            if(n==3 || n==2 || n==1 || n==0)
            {
                System.out.println("NO");
            }
            for(j=2;j<d2;j++)
            {
                if(d%j==0 && fg==0)
                {
                    a=j;
                    fg=1;
                    d=d/a;
                }
                else if(d%j==0 && fg==1)
                {
                    b=j;
                    c=d/b;
                    if(a==c || b==c)
                    {
                        j=a+1;
                        a=0;b=0;c=0;
                        d=n;
                        fg=0;
                    }
                    else
                    {
                        System.out.println("YES");
                        System.out.println(a+" "+b+" "+c);
                        break;
                    }
                }
                else
                {
                    ;
                }
                if(j>=d)
                {
                    System.out.println("NO");
                    break;
                }
                if(j==d2-1)
                {
                    if(c==0)
                    System.out.println("NO");
                }
            }
        }
    }
}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    String nextLine() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c != 10 && c != 13; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    char nextChar() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        return (char) c;
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}


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

import javax.lang.model.util.ElementScanner6;

import java.lang.*;
import java.io.*;

public class Solution
{
    public static void main(String args[])throws IOException
    {/*
        InputStreamReader isr=new InputStreamReader(System.in);
        BufferedReader br=new BufferedReader(isr);
        int a=Integer.parseInt(br.readLine());*/
        FastReader in=new FastReader(System.in);
        long n,d,a,b,c;
        long i,j,k=0;

        int t=in.nextInt();
        for(i=0;i<t;i++)
        {
            n=in.nextLong();
            d=n;
            int fg=0;int fg2=0;
            a=0;
            b=0;
            c=0;
            for(j=2;j<d;j++)
            {
                if(d%j==0 && fg==0)
                {
                    a=j;
                    fg=1;
                    fg2=1;
                    d=d/a;
                }
                else if(d%j==0 && fg==1)
                {
                    b=j;
                    c=d/b;
                    if(a==c || b==c)
                    {
                        j=a+1;
                        a=0;b=0;c=0;
                        d=n;
                        fg=0;
                    }
                    else
                    {
                        System.out.println(n+" YES");
                        System.out.println(a+" "+b+" "+c);
                        break;
                    }
                }
                else
                {
                    ;
                }
                if(j>=d)
                {
                    System.out.println(n+" NO");
                    break;
                }
            }
            if(fg2==0)
                System.out.println(n+" NO");
        }
    }
}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    String nextLine() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c != 10 && c != 13; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    char nextChar() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        return (char) c;
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}


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

import javax.lang.model.util.ElementScanner6;

import java.lang.*;
import java.io.*;

public class Solution
{
    public static void main(String args[])throws IOException
    {/*
        InputStreamReader isr=new InputStreamReader(System.in);
        BufferedReader br=new BufferedReader(isr);
        int a=Integer.parseInt(br.readLine());*/
        FastReader in=new FastReader(System.in);
        long n,d,d2,a,b,c;
        long i,j,k=0;

        int t=in.nextInt();
        for(i=0;i<t;i++)
        {
            n=in.nextLong();
            d=n;
            d2=(long)Math.sqrt(n)+1;
            int fg=0;
            a=0;
            b=0;
            c=0;
            if(n==2 || n==1 || n==0)
            {
                System.out.println("NO");
            }
            for(j=2;j<d2;j++)
            {
                if(d%j==0 && fg==0)
                {
                    a=j;
                    fg=1;
                    d=d/a;
                }
                else if(d%j==0 && fg==1)
                {
                    b=j;
                    c=d/b;
                    if(a==c || b==c)
                    {
                        j=a+1;
                        a=0;b=0;c=0;
                        d=n;
                        fg=0;
                    }
                    else
                    {
                        System.out.println("YES");
                        System.out.println(a+" "+b+" "+c);
                        break;
                    }
                }
                else
                {
                    ;
                }
                if(j>=d)
                {
                    System.out.println("NO");
                    break;
                }
                if(j==d2-1)
                {
                    if(c==0)
                    System.out.println("NO");
                }
            }
        }
    }
}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    String nextLine() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c != 10 && c != 13; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    char nextChar() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        return (char) c;
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}


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

import javax.lang.model.util.ElementScanner6;

import java.lang.*;
import java.io.*;

public class Solution
{
    public static void main(String args[])throws IOException
    {/*
        InputStreamReader isr=new InputStreamReader(System.in);
        BufferedReader br=new BufferedReader(isr);
        int a=Integer.parseInt(br.readLine());*/
        FastReader in=new FastReader(System.in);
        long n,d,a,b,c;
        long i,j,k=0;

        int t=in.nextInt();
        for(i=0;i<t;i++)
        {
            n=in.nextLong();
            d=n;
            int fg=0;
            a=0;
            b=0;
            c=0;
            for(j=2;j<d;j++)
            {
                if(d%j==0 && fg==0)
                {
                    a=j;
                    fg=1;
                    d=d/a;
                }
                else if(d%j==0 && fg==1)
                {
                    b=j;
                    c=d/b;
                    if(a==c || b==c)
                    {
                        j=a+1;
                        a=0;b=0;c=0;
                        d=n;
                        fg=0;
                    }
                    else
                    {
                        System.out.println("YES");
                        System.out.println(a+" "+b+" "+c);
                        break;
                    }
                }
                else
                {
                    ;
                }
                if(j>=d)
                {
                    System.out.println("NO");
                    break;
                }
            }
            if(c==0)
            System.out.println("NO");
        }
    }
}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    String nextLine() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c != 10 && c != 13; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    char nextChar() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        return (char) c;
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}


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

import javax.lang.model.util.ElementScanner6;

import java.lang.*;
import java.io.*;

public class Solution
{
    public static void main(String args[])throws IOException
    {/*
        InputStreamReader isr=new InputStreamReader(System.in);
        BufferedReader br=new BufferedReader(isr);
        int a=Integer.parseInt(br.readLine());*/
        FastReader in=new FastReader(System.in);
        long n,d,a,b,c;
        long i,j,k=0;

        int t=in.nextInt();
        for(i=0;i<t;i++)
        {
            n=in.nextLong();
            d=n;
            int fg=0;
            a=0;
            b=0;
            c=0;
            if(n==2 || n==1 || n==0)
            {
                System.out.println("NO");
            }
            for(j=2;j<d;j++)
            {
                if(d%j==0 && fg==0)
                {
                    a=j;
                    fg=1;
                    d=d/a;
                }
                else if(d%j==0 && fg==1)
                {
                    b=j;
                    c=d/b;
                    if(a==c || b==c)
                    {
                        j=a+1;
                        a=0;b=0;c=0;
                        d=n;
                        fg=0;
                    }
                    else
                    {
                        System.out.println("YES");
                        System.out.println(a+" "+b+" "+c);
                        break;
                    }
                }
                else
                {
                    ;
                }
                if(j>=d)
                {
                    System.out.println("NO");
                    break;
                }
                if(j==d-1)
                {
                    if(c==0)
                    System.out.println("NO");
                }
            }
        }
    }
}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    String nextLine() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c != 10 && c != 13; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    char nextChar() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        return (char) c;
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}


import java.util.*;
import java.util.Map.Entry;
import java.lang.*;
import java.math.*;
import java.text.*;
import java.io.*;
		public final class Solve {
		static PrintWriter out = new PrintWriter(System.out);
		static void flush() {
	 	out.flush();
	 	}
		static void run(long s, long e) {
		NumberFormat formatter = new DecimalFormat("#0.00000");
		System.out.print("Execution time is " + formatter.format((e - s) / 1000d) + " seconds");
		}
		static int gcd(int a, int b) {
			if (b == 0) return a;
			return gcd(b, a % b);
		}
		static long gcd(long a, long b) {
			if (b == 0) return a;
			return gcd(b, a % b);
		}
		static long lcm(long a, long b) {
			return a*b/gcd(a, b);
		}
		static class FastReader {
	     static BufferedReader br;
	    StringTokenizer st;

	    public FastReader() {
	    br = new BufferedReader(new
	    InputStreamReader(System.in));
	    }
	    static boolean isPalindrome(String str1, String str2) {
	    String str3 = str1+str2;
	    int i = 0, j = str3.length()-1;
	    while(i < j) {
	    char a = str3.charAt(i), b = str3.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    static boolean isPalindrome(String str) {
	    int i = 0, j = str.length()-1;
	    while(i < j) {
	    char a = str.charAt(i), b = str.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    String next() {
	    while (st == null || !st.hasMoreElements()) {
	    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());}
	    static int fact(int n) {
	    if(n == 1) return 1;
	    return n * fact(n-1);
	   	}
	    public int[] readIntArray(int n) {
	    int[] arr = new int[n];
		for(int i=0; i<n; ++i)
		arr[i]=nextInt();
		return arr;
		}
	    public long[] readLongArray(int n) {
	    	long[] arr = new long[n];
	    	for(int i=0; i<n; ++i)
	    		arr[i]=nextLong();
	    	return arr;
	    }
	    public int[][] readIntArray(int m, int n){
		int[][] arr = new int[m][n];
		for(int i = 0;i<m;i++)
		for(int j = 0;j<n;j++)
		arr[i][j] = nextInt();
		return arr;
	    }
	    public String[] readStringArray(int n) {
		String[] arr = new String[n];
		for(int i=0; i<n; ++i)
		arr[i]= nextLine();
		return arr;
	    }
	    double nextDouble() {return Double.parseDouble(next());}
	    String nextLine() {
	    String str = "";
	    try{str = br.readLine();}
	    catch (IOException e) {e.printStackTrace();}
	    return str;}
	    }
		static void solve(int n){
			int k = n;
			int c = 0;
			List<Integer> list = new ArrayList<>();
			for(int i = 2;i*i <= 1000000000;i++) {
				if(k%i == 0) {
					k = k/i;
					list.add(i);
					c++;
				}
				if(c == 3) break;
			}
			if(c == 3) {
				out.println("Yes");
				out.println(list.get(0)+" "+list.get(1)+" "+list.get(2));
			}
			else out.println("No");
		}
		public static void main(String args[]) throws IOException {
	    FastReader sc = new FastReader();
	    long s1 = System.currentTimeMillis();
	    int t = sc.nextInt();
	    while(t-- > 0 ) {
	    	int n = sc.nextInt();
	    	solve(n);
	    }
	    flush();
	    long e = System.currentTimeMillis();
//	    run(s1,e);
	    }
	}


import java.util.*;
import java.util.Map.Entry;
import java.lang.*;
import java.math.*;
import java.text.*;
import java.io.*;
		public final class Solve {
		static PrintWriter out = new PrintWriter(System.out);
		static void flush() {
	 	out.flush();
	 	}
		static void run(long s, long e) {
		NumberFormat formatter = new DecimalFormat("#0.00000");
		System.out.print("Execution time is " + formatter.format((e - s) / 1000d) + " seconds");
		}
		static int gcd(int a, int b) {
			if (b == 0) return a;
			return gcd(b, a % b);
		}
		static long gcd(long a, long b) {
			if (b == 0) return a;
			return gcd(b, a % b);
		}
		static long lcm(long a, long b) {
			return a*b/gcd(a, b);
		}
		static class FastReader {
	     static BufferedReader br;
	    StringTokenizer st;

	    public FastReader() {
	    br = new BufferedReader(new
	    InputStreamReader(System.in));
	    }
	    static boolean isPalindrome(String str1, String str2) {
	    String str3 = str1+str2;
	    int i = 0, j = str3.length()-1;
	    while(i < j) {
	    char a = str3.charAt(i), b = str3.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    static boolean isPalindrome(String str) {
	    int i = 0, j = str.length()-1;
	    while(i < j) {
	    char a = str.charAt(i), b = str.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    String next() {
	    while (st == null || !st.hasMoreElements()) {
	    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());}
	    static int fact(int n) {
	    if(n == 1) return 1;
	    return n * fact(n-1);
	   	}
	    public int[] readIntArray(int n) {
	    int[] arr = new int[n];
		for(int i=0; i<n; ++i)
		arr[i]=nextInt();
		return arr;
		}
	    public long[] readLongArray(int n) {
	    	long[] arr = new long[n];
	    	for(int i=0; i<n; ++i)
	    		arr[i]=nextLong();
	    	return arr;
	    }
	    public int[][] readIntArray(int m, int n){
		int[][] arr = new int[m][n];
		for(int i = 0;i<m;i++)
		for(int j = 0;j<n;j++)
		arr[i][j] = nextInt();
		return arr;
	    }
	    public String[] readStringArray(int n) {
		String[] arr = new String[n];
		for(int i=0; i<n; ++i)
		arr[i]= nextLine();
		return arr;
	    }
	    double nextDouble() {return Double.parseDouble(next());}
	    String nextLine() {
	    String str = "";
	    try{str = br.readLine();}
	    catch (IOException e) {e.printStackTrace();}
	    return str;}
	    }
		static void solve(int n){
			int k = n,c = 0;
			int j = 0;
			List<Integer> list = new ArrayList<>();
			int fl = 0;
			Set<Integer> set = new HashSet<>();
			for(int i = 2;i*i <= 1000000000;i++) {
				if(k%i == 0) {
					k = k/i;
					list.add(i);
					set.add(i);
					c++;
				}
				if(c == 2) {
					if(!set.contains(k) && k != 1) {
					list.add(k);
					fl = 1;
					}
					break;
				}
			}
			if(c == 2 && fl == 1) {
				out.println("Yes");
				out.println(list.get(0)+" "+list.get(1)+" "+list.get(2));
			}
			else out.println("No");
		}
		public static void main(String args[]) throws IOException {
	    FastReader sc = new FastReader();
	    long s1 = System.currentTimeMillis();
	    int t = sc.nextInt();
	    while(t-- > 0 ) {
	    	int n = sc.nextInt();
	    	solve(n);
	    }
	    flush();
	    long e = System.currentTimeMillis();
//	    run(s1,e);
	    }
	}


import java.util.*;
import java.util.Map.Entry;
import java.lang.*;
import java.math.*;
import java.text.*;
import java.io.*;
		public final class Solve {
		static PrintWriter out = new PrintWriter(System.out);
		static void flush() {
	 	out.flush();
	 	}
		static void run(long s, long e) {
		NumberFormat formatter = new DecimalFormat("#0.00000");
		System.out.print("Execution time is " + formatter.format((e - s) / 1000d) + " seconds");
		}
		static int gcd(int a, int b) {
			if (b == 0) return a;
			return gcd(b, a % b);
		}
		static long gcd(long a, long b) {
			if (b == 0) return a;
			return gcd(b, a % b);
		}
		static long lcm(long a, long b) {
			return a*b/gcd(a, b);
		}
		static class FastReader {
	     static BufferedReader br;
	    StringTokenizer st;

	    public FastReader() {
	    br = new BufferedReader(new
	    InputStreamReader(System.in));
	    }
	    static boolean isPalindrome(String str1, String str2) {
	    String str3 = str1+str2;
	    int i = 0, j = str3.length()-1;
	    while(i < j) {
	    char a = str3.charAt(i), b = str3.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    static boolean isPalindrome(String str) {
	    int i = 0, j = str.length()-1;
	    while(i < j) {
	    char a = str.charAt(i), b = str.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    String next() {
	    while (st == null || !st.hasMoreElements()) {
	    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());}
	    static int fact(int n) {
	    if(n == 1) return 1;
	    return n * fact(n-1);
	   	}
	    public int[] readIntArray(int n) {
	    int[] arr = new int[n];
		for(int i=0; i<n; ++i)
		arr[i]=nextInt();
		return arr;
		}
	    public long[] readLongArray(int n) {
	    	long[] arr = new long[n];
	    	for(int i=0; i<n; ++i)
	    		arr[i]=nextLong();
	    	return arr;
	    }
	    public int[][] readIntArray(int m, int n){
		int[][] arr = new int[m][n];
		for(int i = 0;i<m;i++)
		for(int j = 0;j<n;j++)
		arr[i][j] = nextInt();
		return arr;
	    }
	    public String[] readStringArray(int n) {
		String[] arr = new String[n];
		for(int i=0; i<n; ++i)
		arr[i]= nextLine();
		return arr;
	    }
	    double nextDouble() {return Double.parseDouble(next());}
	    String nextLine() {
	    String str = "";
	    try{str = br.readLine();}
	    catch (IOException e) {e.printStackTrace();}
	    return str;}
	    }
		static void solve(int n){
			int k = n,c = 0;
			int j = 0;
			List<Integer> list = new ArrayList<>();
			for(int i = 2;i*i <= 1000000000;i++) {
				if(k%i == 0) {
					if(c >= 2) {
						c++;
						list.add(k);
						break;
					}
					k = k/i;
					list.add(i);
					c++;
				}

			}
			if(c >= 3) {
				out.println("Yes");
				out.println(list.get(0)+" "+list.get(1)+" "+list.get(2));
			}
			else out.println("No");
		}
		public static void main(String args[]) throws IOException {
	    FastReader sc = new FastReader();
	    long s1 = System.currentTimeMillis();
	    int t = sc.nextInt();
	    while(t-- > 0 ) {
	    	int n = sc.nextInt();
	    	solve(n);
	    }
	    flush();
	    long e = System.currentTimeMillis();
//	    run(s1,e);
	    }
	}


import java.util.*;
import java.util.Map.Entry;
import java.lang.*;
import java.math.*;
import java.text.*;
import java.io.*;
		public final class Solve {
		static PrintWriter out = new PrintWriter(System.out);
		static void flush() {
	 	out.flush();
	 	}
		static void run(long s, long e) {
		NumberFormat formatter = new DecimalFormat("#0.00000");
		System.out.print("Execution time is " + formatter.format((e - s) / 1000d) + " seconds");
		}
		static int gcd(int a, int b) {
			if (b == 0) return a;
			return gcd(b, a % b);
		}
		static long gcd(long a, long b) {
			if (b == 0) return a;
			return gcd(b, a % b);
		}
		static long lcm(long a, long b) {
			return a*b/gcd(a, b);
		}
		static class FastReader {
	     static BufferedReader br;
	    StringTokenizer st;

	    public FastReader() {
	    br = new BufferedReader(new
	    InputStreamReader(System.in));
	    }
	    static boolean isPalindrome(String str1, String str2) {
	    String str3 = str1+str2;
	    int i = 0, j = str3.length()-1;
	    while(i < j) {
	    char a = str3.charAt(i), b = str3.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    static boolean isPalindrome(String str) {
	    int i = 0, j = str.length()-1;
	    while(i < j) {
	    char a = str.charAt(i), b = str.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    String next() {
	    while (st == null || !st.hasMoreElements()) {
	    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());}
	    static int fact(int n) {
	    if(n == 1) return 1;
	    return n * fact(n-1);
	   	}
	    public int[] readIntArray(int n) {
	    int[] arr = new int[n];
		for(int i=0; i<n; ++i)
		arr[i]=nextInt();
		return arr;
		}
	    public long[] readLongArray(int n) {
	    	long[] arr = new long[n];
	    	for(int i=0; i<n; ++i)
	    		arr[i]=nextLong();
	    	return arr;
	    }
	    public int[][] readIntArray(int m, int n){
		int[][] arr = new int[m][n];
		for(int i = 0;i<m;i++)
		for(int j = 0;j<n;j++)
		arr[i][j] = nextInt();
		return arr;
	    }
	    public String[] readStringArray(int n) {
		String[] arr = new String[n];
		for(int i=0; i<n; ++i)
		arr[i]= nextLine();
		return arr;
	    }
	    double nextDouble() {return Double.parseDouble(next());}
	    String nextLine() {
	    String str = "";
	    try{str = br.readLine();}
	    catch (IOException e) {e.printStackTrace();}
	    return str;}
	    }
		static void solve(int n){
			int k = n,c = 0;
			int j = 0;
			List<Integer> list = new ArrayList<>();
			int fl = 0;
			Set<Integer> set = new HashSet<>();
			for(int i = 2;i*i <= 1000000000;i++) {
				if(k%i == 0) {
					k = k/i;
					list.add(i);
					set.add(i);
					c++;
				}
				if(c == 2) {
					if(!set.contains(k)) {
					list.add(k);
					fl = 1;
					}
					break;
				}
			}
			if(c == 2 && fl == 1) {
				out.println("Yes");
				out.println(list.get(0)+" "+list.get(1)+" "+list.get(2));
			}
			else out.println("No");
		}
		public static void main(String args[]) throws IOException {
	    FastReader sc = new FastReader();
	    long s1 = System.currentTimeMillis();
	    int t = sc.nextInt();
	    while(t-- > 0 ) {
	    	int n = sc.nextInt();
	    	solve(n);
	    }
	    flush();
	    long e = System.currentTimeMillis();
//	    run(s1,e);
	    }
	}


import java.util.*;
import java.util.Map.Entry;
import java.lang.*;
import java.math.*;
import java.text.*;
import java.io.*;
		public final class Solve {
		static PrintWriter out = new PrintWriter(System.out);
		static void flush() {
	 	out.flush();
	 	}
		static void run(long s, long e) {
		NumberFormat formatter = new DecimalFormat("#0.00000");
		System.out.print("Execution time is " + formatter.format((e - s) / 1000d) + " seconds");
		}
		static int gcd(int a, int b) {
			if (b == 0) return a;
			return gcd(b, a % b);
		}
		static long gcd(long a, long b) {
			if (b == 0) return a;
			return gcd(b, a % b);
		}
		static long lcm(long a, long b) {
			return a*b/gcd(a, b);
		}
		static class FastReader {
	     static BufferedReader br;
	    StringTokenizer st;

	    public FastReader() {
	    br = new BufferedReader(new
	    InputStreamReader(System.in));
	    }
	    static boolean isPalindrome(String str1, String str2) {
	    String str3 = str1+str2;
	    int i = 0, j = str3.length()-1;
	    while(i < j) {
	    char a = str3.charAt(i), b = str3.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    static boolean isPalindrome(String str) {
	    int i = 0, j = str.length()-1;
	    while(i < j) {
	    char a = str.charAt(i), b = str.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    String next() {
	    while (st == null || !st.hasMoreElements()) {
	    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());}
	    static int fact(int n) {
	    if(n == 1) return 1;
	    return n * fact(n-1);
	   	}
	    public int[] readIntArray(int n) {
	    int[] arr = new int[n];
		for(int i=0; i<n; ++i)
		arr[i]=nextInt();
		return arr;
		}
	    public long[] readLongArray(int n) {
	    	long[] arr = new long[n];
	    	for(int i=0; i<n; ++i)
	    		arr[i]=nextLong();
	    	return arr;
	    }
	    public int[][] readIntArray(int m, int n){
		int[][] arr = new int[m][n];
		for(int i = 0;i<m;i++)
		for(int j = 0;j<n;j++)
		arr[i][j] = nextInt();
		return arr;
	    }
	    public String[] readStringArray(int n) {
		String[] arr = new String[n];
		for(int i=0; i<n; ++i)
		arr[i]= nextLine();
		return arr;
	    }
	    double nextDouble() {return Double.parseDouble(next());}
	    String nextLine() {
	    String str = "";
	    try{str = br.readLine();}
	    catch (IOException e) {e.printStackTrace();}
	    return str;}
	    }
		static void solve(int n){
			int k = n;
			int c = 0;
			List<Integer> list = new ArrayList<>();
			for(int i = 2;i*i <= 1000000000;i++) {
				if(k%i == 0) {
					k = k/i;
					list.add(i);
					c++;
				}
				if(c == 3) break;
			}
			if(c == 3) {
				out.println("Yes");
				out.println(list.get(0)+" "+list.get(1)+" "+list.get(2));
			}
			else if(c == 2 && list.get(0)*list.get(1) == n) {
				out.println("Yes");
				out.println(1+" "+list.get(0)+" "+list.get(1));
			}
			else out.println("No");
		}
		public static void main(String args[]) throws IOException {
	    FastReader sc = new FastReader();
	    long s1 = System.currentTimeMillis();
	    int t = sc.nextInt();
	    while(t-- > 0 ) {
	    	int n = sc.nextInt();
	    	solve(n);
	    }
	    flush();
	    long e = System.currentTimeMillis();
//	    run(s1,e);
	    }
	}


import java.util.*;
import java.util.Map.Entry;
import java.lang.*;
import java.math.*;
import java.text.*;
import java.io.*;
		public final class Solve {
		static PrintWriter out = new PrintWriter(System.out);
		static void flush() {
	 	out.flush();
	 	}
		static void run(long s, long e) {
		NumberFormat formatter = new DecimalFormat("#0.00000");
		System.out.print("Execution time is " + formatter.format((e - s) / 1000d) + " seconds");
		}
		static int gcd(int a, int b) {
			if (b == 0) return a;
			return gcd(b, a % b);
		}
		static long gcd(long a, long b) {
			if (b == 0) return a;
			return gcd(b, a % b);
		}
		static long lcm(long a, long b) {
			return a*b/gcd(a, b);
		}
		static class FastReader {
	     static BufferedReader br;
	    StringTokenizer st;

	    public FastReader() {
	    br = new BufferedReader(new
	    InputStreamReader(System.in));
	    }
	    static boolean isPalindrome(String str1, String str2) {
	    String str3 = str1+str2;
	    int i = 0, j = str3.length()-1;
	    while(i < j) {
	    char a = str3.charAt(i), b = str3.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    static boolean isPalindrome(String str) {
	    int i = 0, j = str.length()-1;
	    while(i < j) {
	    char a = str.charAt(i), b = str.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    String next() {
	    while (st == null || !st.hasMoreElements()) {
	    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());}
	    static int fact(int n) {
	    if(n == 1) return 1;
	    return n * fact(n-1);
	   	}
	    public int[] readIntArray(int n) {
	    int[] arr = new int[n];
		for(int i=0; i<n; ++i)
		arr[i]=nextInt();
		return arr;
		}
	    public long[] readLongArray(int n) {
	    	long[] arr = new long[n];
	    	for(int i=0; i<n; ++i)
	    		arr[i]=nextLong();
	    	return arr;
	    }
	    public int[][] readIntArray(int m, int n){
		int[][] arr = new int[m][n];
		for(int i = 0;i<m;i++)
		for(int j = 0;j<n;j++)
		arr[i][j] = nextInt();
		return arr;
	    }
	    public String[] readStringArray(int n) {
		String[] arr = new String[n];
		for(int i=0; i<n; ++i)
		arr[i]= nextLine();
		return arr;
	    }
	    double nextDouble() {return Double.parseDouble(next());}
	    String nextLine() {
	    String str = "";
	    try{str = br.readLine();}
	    catch (IOException e) {e.printStackTrace();}
	    return str;}
	    }
		static void solve(int n){
			int k = n,c = 0;
			int j = 0;
			List<Integer> list = new ArrayList<>();
			Set<Integer> set = new HashSet<>();
			for(int i = 2;i*i <= 1000000000;i++) {
				if(k%i == 0) {
					k = k/i;
					list.add(i);
					set.add(i);
					c++;
				}
				if(c == 2 && !set.contains(k)) {
					c++;
					list.add(k);
					break;
				}

			}
			if(c >= 3) {
				out.println("Yes");
				out.println(list.get(0)+" "+list.get(1)+" "+list.get(2));
			}
			else out.println("No");
		}
		public static void main(String args[]) throws IOException {
	    FastReader sc = new FastReader();
	    long s1 = System.currentTimeMillis();
	    int t = sc.nextInt();
	    while(t-- > 0 ) {
	    	int n = sc.nextInt();
	    	solve(n);
	    }
	    flush();
	    long e = System.currentTimeMillis();
//	    run(s1,e);
	    }
	}


import java.util.*;
import java.util.Map.Entry;
import java.lang.*;
import java.math.*;
import java.text.*;
import java.io.*;
		public final class Solve {
		static PrintWriter out = new PrintWriter(System.out);
		static void flush() {
	 	out.flush();
	 	}
		static void run(long s, long e) {
		NumberFormat formatter = new DecimalFormat("#0.00000");
		System.out.print("Execution time is " + formatter.format((e - s) / 1000d) + " seconds");
		}
		static int gcd(int a, int b) {
			if (b == 0) return a;
			return gcd(b, a % b);
		}
		static long gcd(long a, long b) {
			if (b == 0) return a;
			return gcd(b, a % b);
		}
		static long lcm(long a, long b) {
			return a*b/gcd(a, b);
		}
		static class FastReader {
	     static BufferedReader br;
	    StringTokenizer st;

	    public FastReader() {
	    br = new BufferedReader(new
	    InputStreamReader(System.in));
	    }
	    static boolean isPalindrome(String str1, String str2) {
	    String str3 = str1+str2;
	    int i = 0, j = str3.length()-1;
	    while(i < j) {
	    char a = str3.charAt(i), b = str3.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    static boolean isPalindrome(String str) {
	    int i = 0, j = str.length()-1;
	    while(i < j) {
	    char a = str.charAt(i), b = str.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    String next() {
	    while (st == null || !st.hasMoreElements()) {
	    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());}
	    static int fact(int n) {
	    if(n == 1) return 1;
	    return n * fact(n-1);
	   	}
	    public int[] readIntArray(int n) {
	    int[] arr = new int[n];
		for(int i=0; i<n; ++i)
		arr[i]=nextInt();
		return arr;
		}
	    public long[] readLongArray(int n) {
	    	long[] arr = new long[n];
	    	for(int i=0; i<n; ++i)
	    		arr[i]=nextLong();
	    	return arr;
	    }
	    public int[][] readIntArray(int m, int n){
		int[][] arr = new int[m][n];
		for(int i = 0;i<m;i++)
		for(int j = 0;j<n;j++)
		arr[i][j] = nextInt();
		return arr;
	    }
	    public String[] readStringArray(int n) {
		String[] arr = new String[n];
		for(int i=0; i<n; ++i)
		arr[i]= nextLine();
		return arr;
	    }
	    double nextDouble() {return Double.parseDouble(next());}
	    String nextLine() {
	    String str = "";
	    try{str = br.readLine();}
	    catch (IOException e) {e.printStackTrace();}
	    return str;}
	    }
		static void solve(int n){
			int k = n;
			int c = 0;
			List<Integer> list = new ArrayList<>();
			int j = 0;
			for(int i = 2;i*i <= 1000000000;i++) {
				if(k%i == 0) {
					j = k;
					k = k/i;
					list.add(i);
					if(c >= 3) {
						list.set(2, list.get(2)*j);
					}
					c++;
				}

			}
			if(c >= 3) {
				out.println("Yes");
				out.println(list.get(0)+" "+list.get(1)+" "+list.get(2));
			}
			else out.println("No");
		}
		public static void main(String args[]) throws IOException {
	    FastReader sc = new FastReader();
	    long s1 = System.currentTimeMillis();
	    int t = sc.nextInt();
	    while(t-- > 0 ) {
	    	int n = sc.nextInt();
	    	solve(n);
	    }
	    flush();
	    long e = System.currentTimeMillis();
//	    run(s1,e);
	    }
	}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static int mod=(int)1e9+7;
    public static void main(String[] args) throws IOException {
        FastReader sc = new FastReader();
        int t=sc.nextInt();
        while (t-->0){
            int n=sc.nextInt();
            HashMap<Integer,Integer> hm= fac(n);
            int[] arr1=new int[hm.size()];
            int[] arr2=new int[hm.size()];
            int count=0;
            for (int x:hm.keySet()){
                arr1[count]=x;
                arr2[count]=hm.get(x);
                count++;
            }
            if (count>=3){
                System.out.println("YES");
                System.out.println(arr1[0]+" "+arr1[1]+" "+n/(arr1[0]*arr1[1]));
            }else if (count==2){
                if (arr2[0]+arr2[1]>=4){
                    System.out.println("YES");
                    System.out.println(arr1[0]+" "+arr1[1]+" "+(n/(arr1[0]*arr1[1])));
                }else System.out.println("NO");
            }else{
                if (arr2[0]>=6){
                    System.out.println("YES");
                    System.out.println(arr1[0]+" "+(arr1[0]*arr1[0])+" "+(n/(arr1[0]*arr1[0]*arr1[0])));
                }else System.out.println("NO");
            }
        }
    }
    static HashMap<Integer, Integer> fac(int x){
        HashMap<Integer,Integer> map=new HashMap<>();
        for (int i=2;i*i<=x;i++){
            int cnt=0;
            boolean f=false;
            while (x%i==0){
                f=true;
                x/=i;
                cnt++;
            }
            if (f)map.put(i,cnt);
        }
        if (x>1)map.put(x,map.getOrDefault(x,0)+1);
        return map;
    }
}
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            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());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static int mod=(int)1e9+7;
    public static void main(String[] args) throws IOException {
        FastReader sc = new FastReader();
        int t=sc.nextInt();
        while (t-->0){
            int n=sc.nextInt();
            HashMap<Integer,Integer> map= fac(n);
            int[] arr1=new int[n];
            int[] arr2=new int[n];
            int count=0;
            for (int x:map.keySet()){
                arr1[count]=x;
                arr2[count]=map.get(x);
                count++;
            }
            StringBuilder sb=new StringBuilder();
            if (count>=3){
                sb.append("YES\n");
                sb.append((arr1[0]+" "+arr1[1]+" "+n/(arr1[0]*arr1[1])));
            }else if (count==2){
                if (arr2[0]+arr2[1]>=4){
                    sb.append("YES\n");
                    sb.append(arr1[0]+" "+arr1[1]+" "+(n/(arr1[0]*arr1[1])));
                }else sb.append("NO");
            }else{
                if (arr2[0]>=6){
                    sb.append("YES\n");
                    sb.append(arr1[0]+" "+(arr1[0]*arr1[0])+" "+(n/(arr1[0]*arr1[0]*arr1[0])));
                }else sb.append("NO");
            }
            System.out.println(sb);
        }
    }
    static HashMap<Integer, Integer> fac(int x){
        HashMap<Integer,Integer> map=new HashMap<>();
        for (int i=2;i*i<=x;i++){
            int cnt=0;
            boolean f=false;
            while (x%i==0){
                f=true;
                x/=i;
                cnt++;
            }
            if (f)map.put(i,cnt);
        }
        if (x>1)map.put(x,map.getOrDefault(x,0)+1);
        return map;
    }
}
class disJoint{
    int[] parent;
    int[] size;
    public disJoint(int n){
        parent=new int[n];
        size=new int[n];
        makeSet();
    }
    public void makeSet(){
        for(int i=0;i<parent.length;i++){
            parent[i]=i;
            size[i]=1;
        }
    }
    public int find(int v){
        if(parent[v]==v)return v;
        else return parent[v]=find(parent[v]);
    }
    public void union(int a,int b){
        a=find(a);
        b=find(b);
        if(a!=b){
            if(size[a]<size[b])parent[a]=b;
            else parent[b]=a;
        }
    }
}
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            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());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static int mod=(int)1e9+7;
    public static void main(String[] args) throws Exception {
        FastReader sc = new FastReader();
        int t=sc.nextInt();
        while(t-->0){
            int n=sc.nextInt();
            if(isPrime(n)) System.out.println("NO");
            else{
                int i=2;
                HashSet<Integer> hs=new HashSet<>();
                while(n>1){
                    if(hs.size()==2){
                        hs.add(n);
                        break;
                    }
                    if(n%i==0){
                        hs.add(i);
                        n=n/i;
                        i++;
                    }
                    else i++;
                }
                if(hs.size()==3){
                    System.out.println("YES");
                    for(int j:hs) System.out.print(j+" ");
                    System.out.println();
                }
                else System.out.println("NO");
            }
        }
    }
    public static boolean isPrime(long n){
        int x=(int)Math.sqrt(n);
        boolean z=true;
        for(int i=2;i<=x;i++){
            if(n%i==0){
                z=false;
                break;
            }
        }
        return z;
    }
}
class disJoint{
    int[] parent;
    int[] size;
    public disJoint(int n){
        parent=new int[n];
        size=new int[n];
        makeSet();
    }
    public void makeSet(){
        for(int i=0;i<parent.length;i++){
            parent[i]=i;
            size[i]=1;
        }
    }
    public int find(int v){
        if(parent[v]==v)return v;
        else return parent[v]=find(parent[v]);
    }
    public void union(int a,int b){
        a=find(a);
        b=find(b);
        if(a!=b){
            if(size[a]<size[b])parent[a]=b;
            else parent[b]=a;
        }
    }
}
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            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());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static int mod=(int)1e9+7;
    public static void main(String[] args) throws IOException {
        FastReader sc = new FastReader();
        int t=sc.nextInt();
        while(t-->0){
            int n=sc.nextInt();
            LinkedList<Integer> ll=factor(n);
            Collections.sort(ll);
            if(ll.size()<2){
                System.out.println("NO");
                continue;
            }
            int a=ll.removeFirst(),b=ll.removeFirst();
            int c=n/(a*b);
            if(a!=b && b!=c && a!=c && c!=1) System.out.println("YES\n"+a+" "+b+" "+c);
            else System.out.println("NO");
        }
    }
    static LinkedList<Integer> factor(int n){
        LinkedList<Integer> ll=new LinkedList<>();
        int x=(int)Math.sqrt(n);
        for(int i=2;i<=x;i++){
            if(n%i==0){
                ll.add(i);
                if(i!=n/i)ll.add(n/i);
            }
        }
        return ll;
    }
}
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            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());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static int mod=(int)1e9+7;
    public static void main(String[] args) throws IOException {
        FastReader sc = new FastReader();
        int t=sc.nextInt();
        while (t-->0){
            int n=sc.nextInt();
            HashMap<Integer,Integer> map= fac(n);
            int[] arr1=new int[n];
            int[] arr2=new int[n];
            int count=0;
            for (int x:map.keySet()){
                arr1[count]=x;
                arr2[count]=map.get(x);
                count++;
            }
            if (count>=3){
                System.out.println("YES");
                System.out.println(arr1[0]+" "+arr1[1]+" "+n/(arr1[0]*arr1[1]));
            }else if (count==2){
                if (arr2[0]+arr2[1]>=4){
                    System.out.println("YES");
                    System.out.println(arr1[0]+" "+arr1[1]+" "+(n/(arr1[0]*arr1[1])));
                }else System.out.println("NO");
            }else{
                if (arr2[0]>=6){
                    System.out.println("YES");
                    System.out.println(arr1[0]+" "+(arr1[0]*arr1[0])+" "+(n/(arr1[0]*arr1[0]*arr1[0])));
                }else System.out.println("NO");
            }
        }
    }
    static HashMap<Integer, Integer> fac(int x){
        HashMap<Integer,Integer> map=new HashMap<>();
        for (int i=2;i*i<=x;i++){
            int cnt=0;
            boolean f=false;
            while (x%i==0){
                f=true;
                x/=i;
                cnt++;
            }
            if (f)map.put(i,cnt);
        }
        if (x>1)map.put(x,map.getOrDefault(x,0)+1);
        return map;
    }
}
class disJoint{
    int[] parent;
    int[] size;
    public disJoint(int n){
        parent=new int[n];
        size=new int[n];
        makeSet();
    }
    public void makeSet(){
        for(int i=0;i<parent.length;i++){
            parent[i]=i;
            size[i]=1;
        }
    }
    public int find(int v){
        if(parent[v]==v)return v;
        else return parent[v]=find(parent[v]);
    }
    public void union(int a,int b){
        a=find(a);
        b=find(b);
        if(a!=b){
            if(size[a]<size[b])parent[a]=b;
            else parent[b]=a;
        }
    }
}
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            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());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static int mod=(int)1e9+7;
    public static void main(String[] args) throws IOException {
        FastReader sc = new FastReader();
        int t=sc.nextInt();
        while(t-->0){
            int n=sc.nextInt();
            HashMap<Integer,Integer> hm=factor(n);
            int[] arr1=new int[hm.size()];
            int[] arr2=new int[hm.size()];
            int i=0;
            for(int x:hm.keySet()){
                arr1[i]=x;
                arr2[i]=hm.get(x);
                i++;
            }
            if(i>=3){
                System.out.println("YES");
                System.out.println(arr1[0]+" "+arr1[1]+" "+n/(arr1[0]*arr1[1]));
            }
            else if(i==2){
                if(arr2[0]+arr2[1]>=4){
                    System.out.println("YES");
                    System.out.println(arr1[0]+" "+arr1[1]+" "+n/(arr1[0]*arr1[1]));
                }
                else System.out.println("NO");
            }
            else{
                if(arr2[0]>=6){
                    System.out.println("YES");
                    System.out.println(arr1[0]+" "+(arr1[0]*arr1[0])+" "+n/(arr1[0]*arr1[0]*arr1[0]));
                }
                else System.out.println("NO");
            }

        }
    }
    static HashMap<Integer,Integer> factor(int n){
        HashMap<Integer,Integer> hm=new HashMap<>();
        for(int i=2;i*i<=n;i++){
            int count=0;
            boolean z=false;
            while(n%i==0){
                n=n/i;
                count++;
                z=true;
            }
            if(z)hm.put(i,count);
        }
        if (n>1)hm.put(n,hm.getOrDefault(n,0)+1);
        return hm;
    }
}
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            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());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static int mod=(int)1e9+7;
    public static void main(String[] args) throws IOException {
        FastReader sc = new FastReader();
        int t=sc.nextInt();
        while(t-->0){
            int n=sc.nextInt();
            LinkedList<Integer> ll=factor(n);
            Collections.sort(ll);
            if(ll.size()<2){
                System.out.println("NO");
                continue;
            }
            int a=ll.removeFirst(),b=ll.removeFirst();
            int c=n/(a*b);
            if(a!=b && b!=c && a!=c && c!=1 && a*b*c==n) System.out.println("YES\n"+a+" "+b+" "+c);
            else System.out.println("NO");
        }
    }
    static LinkedList<Integer> factor(int n){
        LinkedList<Integer> ll=new LinkedList<>();
        int x=(int)Math.sqrt(n);
        for(int i=2;i<=x;i++){
            if(n%i==0){
                ll.add(i);
                if(i!=n/i)ll.add(n/i);
            }
        }
        return ll;
    }
}
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            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());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


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

public class mult {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt(),x=0,y=0,z=0;
		for(int k=t;k>0;k--) {
		   int n=sc.nextInt(),a=1,m=-1;
		   for(int i=2;i<=MAth.sqrt(n);i++){
		        for(int j=3;j<=Math.sqrt(n);j++){
		         a=n/(i*j);
		         if(a!=i && a!=j && a*i*j==n && a>=2 && i!=j){
		              m=1;
		            x=i;
		            y=j;
		            z=a;
		         }
		         if(m==1)
		        	 break;
		        }
		   }
		   if(m==1) {
		   System.out.println("YES");
           System.out.println(x +" "+ y + " " + z);
		   }
		   if(m==-1)
		   System.out.println("NO");

		         }
		        }
		   }


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

public class mult {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt(),x=0,y=0,z=0;
		for(int k=t;k>0;k--) {
		   int n=sc.nextInt(),a=1,m=-1;
		   for(int i=2;i<=Math.sqrt(n);i++){
		        for(int j=3;j<=Math.sqrt(n);j++){
		         a=n/(i*j);
		         if(a!=i && a!=j && a*i*j==n && a>=2 && i!=j){
		              m=1;
		            x=i;
		            y=j;
		            z=a;
		         }
		         if(m==1)
		        	 break;
		        }
		   }
		   if(m==1) {
		   System.out.println("YES");
           System.out.println(x +" "+ y + " " + z);
		   }
		   if(m==-1)
		   System.out.println("NO");

		         }
		        }
		   }


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

public class mult {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt(),x=0,y=0,z=0;
		for(int k=t;k>0;k--) {
		   int n=sc.nextInt(),a=1,m=-1;
		   for(int i=2;i<=Math.sqrt(n);i++){
		        for(int j=i+1;j<=Math.sqrt(n);j++){
		         a=n/(i*j);
		         if(a!=i && a!=j && a*i*j==n && a>=2 && i!=j){
		              m=1;
		            x=i;
		            y=j;
		            z=a;
		         }
		         if(m==1)
		        	 break;
		        }
		   }
		   if(m==1) {
		   System.out.println("YES");
           System.out.println(x +" "+ y + " " + z);
		   }
		   if(m==-1)
		   System.out.println("NO");

		         }
		        }
		   }


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

public class mult {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt(),x=0,y=0,z=0;
		for(int k=t;k>0;k--) {
		   int n=sc.nextInt(),a=1,m=-1;
		   for(int i=2;i<=n;i++){
		        for(int j=2;j<=n;j++){
		         a=n/(i*j);
		         if(a!=i && a!=j && a*i*j==n){
		              m=1;
		            x=i;
		            y=j;
		            z=a;
		         }
		         if(m==1)
		        	 break;
		        }
		   }
		   if(m==1) {
		   System.out.println("YES");
           System.out.println(x +" "+ y + " " + z);
		   }
		   if(m==-1)
		   System.out.println("NO");

		         }
		        }
		   }


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

public class mult {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt(),x=0,y=0,z=0;
		for(int k=t;k>0;k--) {
		   int n=sc.nextInt(),a=1,m=-1;
		   for(int i=2;i<=MAth.sqrt(n);i++){
		        for(int j=3;j<=Math.sqrt(n);j++){
		         a=n/(i*j);
		         if(a!=i && a!=j && a*i*j==n && a>=2 && i!=j){
		              m=1;
		            x=i;
		            y=j;
		            z=a;
		         }
		         if(m==1)
		        	 break;
		        }
		   }
		   if(m==1) {
		   System.out.println("YES");
           System.out.println(x +" "+ y + " " + z);
		   }
		   if(m==-1)
		   System.out.println("NO");

		         }
		        }
		   }


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

public class mult {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt(),x=0,y=0,z=0;
		for(int k=t;k>0;k--) {
		   int n=sc.nextInt(),a=1,m=-1;
		   for(int i=2;i<=n/8;i++){
		        for(int j=3;j<=n/8;j++){
		         a=n/(i*j);
		         if(a!=i && a!=j && a*i*j==n && a>=2 && i!=j){
		              m=1;
		            x=i;
		            y=j;
		            z=a;
		         }
		         if(m==1)
		        	 break;
		        }
		   }
		   if(m==1) {
		   System.out.println("YES");
           System.out.println(x +" "+ y + " " + z);
		   }
		   if(m==-1)
		   System.out.println("NO");

		         }
		        }
		   }


import java.util.*;
public class gxtgd {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t--!=0) {
		int n=sc.nextInt(),x=0,y=0;
		for(int i=2;i*i<=n;i++) {
			if(n%i==0) {
				x=i;
				break;
			}

		}
		for(int i=3;i*i<=n;i++) {
			if(n%(x*i)==0 && i!=x) {
				y=i;
				break;
			}

		}
		if(n%(x*y)==0 && n/(x*y)!=x && n/(x*y)!=y && n%(x*y)!=1) {
			System.out.println("YES");
			System.out.println(x +" " +y+ " " + n/(x*y));
		}
		else
			System.out.println("NO");
	}
	}
}


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

public class mult {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt(),x=0,y=0,z=0;
		for(int k=t;k>0;k--) {
		   int n=sc.nextInt(),a=1,m=-1;
		   for(int i=2;i<=n;i++){
		        for(int j=2;j<=n;j++){
		         a=n/(i*j);
		         if(a!=i && a!=j && a*i*j==n && a>=2){
		              m=1;
		            x=i;
		            y=j;
		            z=a;
		         }
		         if(m==1)
		        	 break;
		        }
		   }
		   if(m==1) {
		   System.out.println("YES");
           System.out.println(x +" "+ y + " " + z);
		   }
		   if(m==-1)
		   System.out.println("NO");

		         }
		        }
		   }


import java.util.*;
public class gxtgd {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t--!=0) {
		int n=sc.nextInt(),x=1,y=1;
		for(int i=2;i*i<=n;i++) {
			if(n%i==0) {
				x=i;
				break;
			}

		}
		for(int i=3;i*i<=n;i++) {
			if(n%(x*i)==0 && i!=x && x!=1) {
				y=i;
				break;
			}

		}
		if(n%(x*y)==0 && n/(x*y)!=x && n/(x*y)!=y && n%(x*y)!=1 && y!=1) {
			System.out.println("YES");
			System.out.println(x +" " +y+ " " + n/(x*y));
		}
		else
			System.out.println("NO");
	}
	}
}


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

public class mult {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt(),x=0,y=0,z=0;
		for(int k=t;k>0;k--) {
		   int n=sc.nextInt(),a=1,m=-1;
		   for(int i=2;i<=Math.sqrt(n);i++){
		        for(int j=i+1;j<=Math.sqrt(n);j++){
		         a=n/(i*j);
		         if(a!=i && a!=j && a*i*j==n && a>=2 && i!=j){
		              m=1;
		           break;
		         }
		         if(m==1)
		        	 break;
		        }
		        break;
		   }
		   if(m==1) {
		   System.out.println("YES");
           System.out.println(i +" "+ j + " " + a);
		   }
		   if(m==-1)
		   System.out.println("NO");

		         }
		        }
		   }


import java.util.*;
public class product
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt(),i=0,j=0;
		for(int k=t;k>0;k--) {
		   int n=sc.nextInt(),a=0,m=-1;
		   for( i=2;i<=Math.sqrt(n);i++){
		        for( j=i+1;j<=Math.sqrt(n);j++){
		         a=n/(i*j);
		         if(a!=i && a!=j && a*i*j==n && a>=2 && i!=j){
		              m=1;
		         }
		         if(m==1)
		        	 break;
		        }
		        if(m==1)
		        break;
		   }
		   if(m==1) {
		   System.out.println("YES");
           System.out.println(i +" "+ j + " " + a);
		   }
		   if(m==-1)
		   System.out.println("NO");

		         }
		        }
		   }


import java.util.*;
public class product
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt(),i=0,j=0,a=0;
		for(int k=t;k>0;k--) {
		   int n=sc.nextInt(),a=1,m=-1;
		   for( i=2;i<=Math.sqrt(n);i++){
		        for( j=i+1;j<=Math.sqrt(n);j++){
		         a=n/(i*j);
		         if(a!=i && a!=j && a*i*j==n && a>=2 && i!=j){
		              m=1;
		           break;
		         }
		         if(m==1)
		        	 break;
		        }
		        break;
		   }
		   if(m==1) {
		   System.out.println("YES");
           System.out.println(i +" "+ j + " " + a);
		   }
		   if(m==-1)
		   System.out.println("NO");

		         }
		        }
		   }


import java.util.*;
public class product
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt(),i=0,j=0;
		for(int k=t;k>0;k--) {
		   int n=sc.nextInt(),a=0,m=-1;
		   for( i=2;i<=Math.sqrt(n);i++){
		        for( j=i+1;j<=Math.sqrt(n);j++){
		         a=n/(i*j);
		         if(a!=i && a!=j && a*i*j==n && a>=2 && i!=j){
		              m=1;
		         }
		         if(m==1)
		        	 break;
		        }
		   }
		   if(m==1) {
		   System.out.println("YES");
           System.out.println(i +" "+ j + " " + a);
		   }
		   if(m==-1)
		   System.out.println("NO");

		         }
		        }
		   }


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

public class mult {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt(),x=0,y=0,z=0;
		for(int k=t;k>0;k--) {
		   int n=sc.nextInt(),a=1,m=-1;
		   for(int i=2;i<=n;i++){
		        for(int j=2;j<=n;j++){
		         a=n/(i*j);
		         if(a!=i && a!=j && a*i*j==n && a>=2 && i!=j){
		              m=1;
		            x=i;
		            y=j;
		            z=a;
		         }
		         if(m==1)
		        	 break;
		        }
		   }
		   if(m==1) {
		   System.out.println("YES");
           System.out.println(x +" "+ y + " " + z);
		   }
		   if(m==-1)
		   System.out.println("NO");

		         }
		        }
		   }


import java.util.*;
public class product
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt(),i=0,j=0;
		for(int k=t;k>0;k--) {
		   int n=sc.nextInt(),a=0,m=-1;
		   for( i=2;i<=Math.sqrt(n);i++){
		        for( j=i+1;j<=Math.sqrt(n);j++){
		         a=n/(i*j);
		         if(a!=i && a!=j && a*i*j==n && a>=2 && i!=j){
		              m=1;
		           break;
		         }
		         if(m==1)
		        	 break;
		        }
		        break;
		   }
		   if(m==1) {
		   System.out.println("YES");
           System.out.println(i +" "+ j + " " + a);
		   }
		   if(m==-1)
		   System.out.println("NO");

		         }
		        }
		   }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

    static private Reader reader = new Reader();

    public static void main(String[] args) {
        int t = reader.nextInt();
        while(t-- > 0) {
            int n = reader.nextInt();
            Set<Integer> result = new HashSet<>();
            int a = 2;
            while(a*a <= n) {
                if(n % a == 0) {
                    result.add(a);
                    break;
                }
                a++;
            }
            int b = a+1;
            while(b*b <= n) {
                if(n % b == 0) {
                    result.add(b);
                    break;
                }
                b++;
            }
            int rem = n;
            rem /= a;
            rem /= b;
            result.add(rem);
            if(result.size() == 3 && rem != 1 && rem * a * b == n) {
                System.out.println("YES");
                for (Integer integer : result) {
                    System.out.print(integer+ " ");
                }
                System.out.println();
            } else {
                System.out.println("NO");
            }
        }
    }

    static class Reader {

        private StringTokenizer st;
        private BufferedReader br;

        Reader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

}


import javafx.util.Pair;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

    static Reader reader = new Reader();

    public static void main(String[] args) {
        int t = reader.nextInt();
        List<Integer> primes = getPrimes();
        while (t-- > 0) {
            int n = reader.nextInt();
            List<Integer> div = new ArrayList<>();
            for(int i = 0; primes.get(i) <= n / 2; i++) {
                if(n % primes.get(i) == 0) {
                    div.add(primes.get(i));
                    for(int j = 2 * primes.get(i); j <= n / 2; j += primes.get(i)) {
                        if(n % j == 0) {
                            div.add(j);
                        }
                    }
                }
            }
            boolean result = false;
            for(int i = 0; i < div.size(); i++) {
                int x = n / div.get(i);
                for(int j = 0, k = div.size() - 1; j < k; ) {
                    if(j == i) {
                        j++;
                    } else if(k == i) {
                        k--;
                    } else if(div.get(j) * div.get(k) == x) {
                        System.out.println("YES\n" + div.get(i) + " " + div.get(j) + " " + div.get(k));
                        result = true;
                        break;
                    } else if(div.get(j) * div.get(k) > x) {
                        k--;
                    } else {
                        j++;
                    }
                }
                if(result) {
                    break;
                }
            }
            if(!result) {
                System.out.println("NO");
            }
        }
    }

    static List<Integer> getPrimes() {
        int MAX = 10000000;
        List<Integer> primes = new ArrayList<>();
        boolean[] isPrime = new boolean[MAX];
        for(int i = 2; i < MAX; i++) {
            isPrime[i] = true;
        }
        for(int i = 2; i < MAX; i++) {
            if(isPrime[i]) {
                primes.add(i);
                for(int j = 2*i; j < MAX; j += i) {
                    isPrime[j] = false;
                }
            }
        }
        return primes;
    }

    static class Reader {
        private BufferedReader br;
        private StringTokenizer st;

        Reader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

    static private Reader reader = new Reader();

    public static void main(String[] args) {
        int t = reader.nextInt();
        while(t-- > 0) {
            int n = reader.nextInt();
            Set<Integer> result = new HashSet<>();
            int a = 2;
            while(a*a <= n) {
                if(n % a == 0) {
                    result.add(a);
                    n /= a;
                    break;
                }
                a++;
            }
            int b = 2;
            while(b*b <= n) {
                if(n % b == 0 && b != a) {
                    result.add(b);
                    n /= b;
                    break;
                }
                b++;
            }
            result.add(n);
            if(result.size() == 3 && n != 1) {
                System.out.println("YES");
                for (Integer integer : result) {
                    System.out.print(integer+ " ");
                }
                System.out.println();
            } else {
                System.out.println("NO");
            }
        }
    }

    static class Reader {

        private StringTokenizer st;
        private BufferedReader br;

        Reader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

}