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

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int tc = sc.nextInt();
        main:
        while (tc-- > 0) {
            int n = sc.nextInt();
            for (int a = 2; 1l * a * a <= n && 1l * a * a * a <= n; a++) {
                if (n % a != 0) continue;
                for (int b = a + 1; 1l * b * b <= n && 1l * b * b * b <= n; b++) {
                    if (n % b != 0) continue;
                    int c = n / (a * b);
                    if (c != a && c != b && c != 1) {
                        out.println("YES");
                        out.println(a + " " + b + " " + c);
                        continue main;
                    }
                }
            }
            out.println("NO");
        }
        out.flush();
        out.close();

    }

    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        boolean ready() throws IOException {
            return br.ready();
        }

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

        public short nextShort() throws IOException {
            return Short.parseShort(next());
        }

    }

}


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

public class Main {

    static class Pair {
        int a, b;
        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
        public String toString() {
            return a+" "+b;
        }
    }

    static HashMap<Integer, Integer> hm = new HashMap<>();

    public static void main(String[] args) throws java.lang.Exception {
        Reader pm =new Reader();
        //Scanner pm = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int t = pm.nextInt();
        while(t-- > 0){
            int n = pm.nextInt();
            hm = new HashMap<>();
            printFac(n);

            if(hm.size() >= 3) {
                System.out.println("YES");
                ArrayList<Long> al = new ArrayList<>();
                int ind = 0;
                for(int i:hm.keySet()) {
                    if(al.size() != 3)
                        al.add((long)Math.pow(i, hm.get(i)));
                    else {
                        al.set(ind, al.get(ind) * (long)Math.pow(i, hm.get(i)));
                        ind++;
                        if(ind == al.size())
                            ind = 0;
                    }
                }
                System.out.println(al.get(0)+" "+al.get(1)+" "+al.get(2));
            }
            else if(hm.size() <= 2) {
                //System.out.println("YES");
                ArrayList<Pair> al = new ArrayList<>();
                int ind = 0;

                for(int i:hm.keySet()) {
                    int pow = hm.get(i);
                    int now = 1;

                    while(pow-now >= 0) {

                        al.add(new Pair(now, i));
                        pow -= now;
                        now++;
                        if(now > pow && pow > 0) {
                            al.add(new Pair(pow, i));
                        }
                    }
                }
                //System.out.println(hm+" "+al);
                //Collections.sort(al);
                if(al.size() < 3) {
                    System.out.println("NO");
                }
                else {

                    ArrayList<Long> ans = new ArrayList<>();

                    for(int i=0;i<al.size();i++) {
                        if(ans.size() < 3) {
                            ans.add((long)Math.pow(al.get(i).b, al.get(i).a));
                        } else {
                            ans.set(ind, (ans.get(ind) * ((long)Math.pow(al.get(i).b, al.get(i).a))));
                            ind++;
                            if(ind == ans.size())
                            ind = 0;
                        }
                    }
                    int fl = 0;
                    HashSet<Long> hs = new HashSet<>();
                    for(int i=0;i<ans.size();i++) {
                        if(hs.contains(ans.get(i))) {
                            fl = 1;
                            break;
                        }
                        hs.add(ans.get(i));

                    }
                    if(fl == 1) {
                        System.out.println("NO");
                    }
                    else {
                        System.out.println("YES");
                        System.out.println(ans.get(0)+" "+ans.get(1)+" "+ans.get(2));
                    }

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

        }
        //end of tests

    }
    //end of main class
    static void printFac(int n) {
        while(n % 2 == 0) {
            hm.merge(2,1,Integer::sum);
            n/=2;
        }
        for(int i=3;i<=Math.sqrt(n);i+=2) {
            if(n % i == 0) {
                n/=i;
                hm.merge(i,1, Integer::sum);
            }
        }
        if(n >  2) {
            hm.merge(n,1, Integer::sum);
        }
    }
    static int countInRange(int arr[], int n, int x, int y) {
        // initialize result
        int count = 0;
        count = upperIndex(arr, n, y) -
                lowerIndex(arr, n, x) + 1;
        return count;
    }

    static int lowerIndex(int arr[], int n, int x) {
        int l = 0, h = n - 1;
        while (l <= h)
        {
            int mid = (l + h) / 2;
            if (arr[mid] >= x)
                h = mid - 1;
            else
                l = mid + 1;
        }
        return l;
    }

    // function to find last index <= y
    static int upperIndex(int arr[], int n, int y) {
        int l = 0, h = n - 1;
        while (l <= h)
        {
            int mid = (l + h) / 2;
            if (arr[mid] <= y)
                l = mid + 1;
            else
                h = mid - 1;
        }
        return h;
    }

    public static StringBuilder dec_to_bin(long n) {
        // decimal to binary upto 30 binaries
        if(n==0) {
            StringBuilder str=new StringBuilder("");
            for(int i=0;i<30;i++) {
                str.append("0");
            }
            return str;
        }
        StringBuilder str=new StringBuilder("");
        while(n!=0) {
            str.append(n%2L);
            n/=2L;
        }
        str=str.reverse();
        StringBuilder tmp_str=new StringBuilder("");
        int len=str.length();
        while(len!=30) {
            tmp_str.append("0");
            len++;
        }
        tmp_str.append(str);
        return tmp_str;
    }

    private static int binarySearchPM(int[] arr, int key){
        int n = arr.length;
        int mid = -1;
        int begin = 0,end=n;
        while(begin <= end){
            mid = (begin+end) / 2;
            if(mid == n){
                return n;
            }
            if(key < arr[mid]){
                end = mid-1;
            } else if(key > arr[mid]){
                begin = mid+1;
            } else {
                return mid;
            }
        }
        //System.out.println(begin+" "+end);
        return -begin; //expected Index
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
}


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

public class Main {

    static class Pair {
        int a, b;
        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
        public String toString() {
            return a+" "+b;
        }
    }

    static HashMap<Integer, Integer> hm = new HashMap<>();

    public static void main(String[] args) throws java.lang.Exception {
        Reader pm =new Reader();
        //Scanner pm = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int t = pm.nextInt();
        while(t-- > 0){
            int n = pm.nextInt();
            hm = new HashMap<>();
            printFac(n);

            if(hm.size() >= 3) {
                System.out.println("YES");
                ArrayList<Long> al = new ArrayList<>();
                int ind = 0;
                for(int i:hm.keySet()) {
                    if(al.size() != 3)
                        al.add((long)Math.pow(i, hm.get(i)));
                    else {
                        al.set(ind, al.get(ind) * (long)Math.pow(i, hm.get(i)));
                        ind++;
                        if(ind == al.size())
                            ind = 0;
                    }
                }
                System.out.println(al.get(0)+" "+al.get(1)+" "+al.get(2));
            }
            else if(hm.size() == 2) {
                //System.out.println("YES");

                ArrayList<Integer> al = new ArrayList<>();
                for(int i:hm.keySet()) {
                    al.add(hm.get(i));
                }
                Collections.sort(al);
                int a = al.get(1);
                int b = al.get(0);
                int max = -1;
                int min = -1;
                ArrayList<Integer> put = new ArrayList<>();
                for(int i:hm.keySet()) {

                    if(hm.get(i) == a) {
                        max = i;
                    }
                    else {
                        min = i;
                    }
                    put.add(i);
                }
                if(a == b) {
                    max = put.get(0);
                    min = put.get(1);
                }
                int fl = 0;
                int pow1 = a-1;
                int pow2 = b-1;
                //System.out.println(pow1+" "+pow2+" "+max+" "+min);
                if(pow1 == 0 && pow2 == 0)
                    fl = 1;
                if(fl == 1) {
                    System.out.println("NO");
                    continue;
                }
                if(pow2 == 0) {

                    long op1 = (long) Math.pow(max, 1);
                    long op2 = (long) Math.pow(max, pow1);
                    long op3 = (long) Math.pow(min, 1);
                    HashSet<Long> chk = new HashSet<>();
                    chk.add(op1);
                    chk.add(op2);
                    chk.add(op3);
                    if(chk.size() < 3) {
                        System.out.println("NO");
                        continue;
                    }
                    System.out.println("YES");
                    System.out.println(op1+" "+op2+" "+op3);
                    continue;
                }
                if(pow1 == 0) {
                    long op1 = (long) Math.pow(max, 1);
                    long op2 = (long) Math.pow(min, pow2);
                    long op3 = (long) Math.pow(min, 1);
                    HashSet<Long> chk = new HashSet<>();
                    chk.add(op1);
                    chk.add(op2);
                    chk.add(op3);
                    if(chk.size() < 3) {
                        System.out.println("NO");
                        continue;
                    }
                    System.out.println("YES");
                    System.out.println(op1+" "+op2+" "+op3);
                    continue;
                }
                if(fl == 1) {
                    System.out.println("NO");
                } else {
                    long op1 = (long) Math.pow(max, 1);
                    long op2 = (long) Math.pow(max, pow1) * (long) Math.pow(min, pow2);;
                    long op3 = (long) Math.pow(min, 1);
                    HashSet<Long> chk = new HashSet<>();
                    chk.add(op1);
                    chk.add(op2);
                    chk.add(op3);
                    if(chk.size() < 3) {
                        System.out.println("NO");
                        continue;
                    }
                    System.out.println("YES");
                    System.out.println(op1+" "+op2+" "+op3);
                }
                // int ind = 0;

                // for(int i:hm.keySet()) {
                //     int pow = hm.get(i);
                //     int now = 1;

                //     while(pow-now >= 0) {

                //         al.add(new Pair(now, i));
                //         pow -= now;
                //         now++;
                //         if(now > pow && pow > 0) {
                //             al.add(new Pair(pow, i));
                //         }
                //     }
                // }
                // System.out.println(hm+" "+al);
                // //Collections.sort(al);
                // if(al.size() < 3) {
                //     System.out.println("NO");
                // }
                // else {

                //     ArrayList<Long> ans = new ArrayList<>();

                //     for(int i=0;i<al.size();i++) {
                //         if(ans.size() < 3) {
                //             ans.add((long)Math.pow(al.get(i).b, al.get(i).a));
                //         } else {
                //             ans.set(ind, (ans.get(ind) * ((long)Math.pow(al.get(i).b, al.get(i).a))));
                //             ind++;
                //             if(ind == ans.size())
                //             ind = 0;
                //         }
                //     }
                //     int fl = 0;
                //     HashSet<Long> hs = new HashSet<>();
                //     for(int i=0;i<ans.size();i++) {
                //         if(hs.contains(ans.get(i))) {
                //             fl = 1;
                //             break;
                //         }
                //         hs.add(ans.get(i));

                //     }
                //     System.out.println(ans);

                //     if(fl == 1) {
                //         System.out.println("NO");
                //     }
                //     else {
                //         System.out.println("YES");
                //         System.out.println(ans.get(0)+" "+ans.get(1)+" "+ans.get(2));
                //     }

                // }
            }
            else if(hm.size() == 1) {
                ArrayList<Integer> al = new ArrayList<>();
                int ele = -1;
                for(int i:hm.keySet()) {
                    ele = i;
                }
                int pow = hm.get(ele);
                if(pow < 6) {
                    System.out.println("NO");
                } else {
                    System.out.println("YES");
                    long op1 = (long) Math.pow(ele, 1);
                    long op2 = (long) Math.pow(ele, 2);
                    long op3 = (long) Math.pow(ele, pow - 3);
                    System.out.println(op1+" "+op2+" "+op3);
                }
            }
            else {
                System.out.println("NO");
            }

        }
        //end of tests

    }
    //end of main class
    static void printFac(int n) {
        while(n % 2 == 0) {
            hm.merge(2,1,Integer::sum);
            n/=2;
        }
        for(int i=3;i<=Math.sqrt(n);i+=2) {
            if(n % i == 0) {
                n/=i;
                hm.merge(i,1, Integer::sum);
            }
        }
        if(n >  2) {
            hm.merge(n,1, Integer::sum);
        }
    }
    static int countInRange(int arr[], int n, int x, int y) {
        // initialize result
        int count = 0;
        count = upperIndex(arr, n, y) -
                lowerIndex(arr, n, x) + 1;
        return count;
    }

    static int lowerIndex(int arr[], int n, int x) {
        int l = 0, h = n - 1;
        while (l <= h)
        {
            int mid = (l + h) / 2;
            if (arr[mid] >= x)
                h = mid - 1;
            else
                l = mid + 1;
        }
        return l;
    }

    // function to find last index <= y
    static int upperIndex(int arr[], int n, int y) {
        int l = 0, h = n - 1;
        while (l <= h)
        {
            int mid = (l + h) / 2;
            if (arr[mid] <= y)
                l = mid + 1;
            else
                h = mid - 1;
        }
        return h;
    }

    public static StringBuilder dec_to_bin(long n) {
        // decimal to binary upto 30 binaries
        if(n==0) {
            StringBuilder str=new StringBuilder("");
            for(int i=0;i<30;i++) {
                str.append("0");
            }
            return str;
        }
        StringBuilder str=new StringBuilder("");
        while(n!=0) {
            str.append(n%2L);
            n/=2L;
        }
        str=str.reverse();
        StringBuilder tmp_str=new StringBuilder("");
        int len=str.length();
        while(len!=30) {
            tmp_str.append("0");
            len++;
        }
        tmp_str.append(str);
        return tmp_str;
    }

    private static int binarySearchPM(int[] arr, int key){
        int n = arr.length;
        int mid = -1;
        int begin = 0,end=n;
        while(begin <= end){
            mid = (begin+end) / 2;
            if(mid == n){
                return n;
            }
            if(key < arr[mid]){
                end = mid-1;
            } else if(key > arr[mid]){
                begin = mid+1;
            } else {
                return mid;
            }
        }
        //System.out.println(begin+" "+end);
        return -begin; //expected Index
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
}


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

public class Main {

    static class Pair {
        int a, b;
        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
        public String toString() {
            return a+" "+b;
        }
    }

    static HashMap<Integer, Integer> hm = new HashMap<>();

    public static void main(String[] args) throws java.lang.Exception {
        Reader pm =new Reader();
        //Scanner pm = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int t = pm.nextInt();
        while(t-- > 0){
            int n = pm.nextInt();
            hm = new HashMap<>();
            printFac(n);

            if(hm.size() >= 3) {
                System.out.println("YES");
                ArrayList<Long> al = new ArrayList<>();
                int ind = 0;
                for(int i:hm.keySet()) {
                    if(al.size() != 3)
                        al.add((long)Math.pow(i, hm.get(i)));
                    else {
                        al.set(ind, al.get(ind) * (long)Math.pow(i, hm.get(i)));
                        ind++;
                        if(ind == al.size())
                            ind = 0;
                    }
                }
                System.out.println(al.get(0)+" "+al.get(1)+" "+al.get(2));
            }
            else if(hm.size() <= 2) {
                //System.out.println("YES");
                ArrayList<Pair> al = new ArrayList<>();
                int ind = 0;

                for(int i:hm.keySet()) {
                    int pow = hm.get(i);
                    int now = 1;

                    while(pow-now >= 0) {

                        al.add(new Pair(now, i));
                        pow -= now;
                        now++;
                        if(now > pow && pow == 1) {
                            al.add(new Pair(pow, i));
                        }
                    }
                }
                //System.out.println(hm+" "+al);
                //Collections.sort(al);
                if(al.size() < 3) {
                    System.out.println("NO");
                }
                else {
                    System.out.println("YES");
                    ArrayList<Long> ans = new ArrayList<>();

                    for(int i=0;i<al.size();i++) {
                        if(ans.size() < 3) {
                            ans.add((long)Math.pow(al.get(i).b, al.get(i).a));
                        } else {
                            ans.set(ind, (ans.get(ind) * ((long)Math.pow(al.get(i).b, al.get(i).a))));
                            ind++;
                            if(ind == ans.size())
                            ind = 0;
                        }
                    }
                    System.out.println(ans.get(0)+" "+ans.get(1)+" "+ans.get(2));
                }
            }
            else {
                System.out.println("NO");
            }

        }
        //end of tests

    }
    //end of main class
    static void printFac(int n) {
        while(n % 2 == 0) {
            hm.merge(2,1,Integer::sum);
            n/=2;
        }
        for(int i=3;i<=Math.sqrt(n);i+=2) {
            if(n % i == 0) {
                n/=i;
                hm.merge(i,1, Integer::sum);
            }
        }
        if(n >  2) {
            hm.merge(n,1, Integer::sum);
        }
    }
    static int countInRange(int arr[], int n, int x, int y) {
        // initialize result
        int count = 0;
        count = upperIndex(arr, n, y) -
                lowerIndex(arr, n, x) + 1;
        return count;
    }

    static int lowerIndex(int arr[], int n, int x) {
        int l = 0, h = n - 1;
        while (l <= h)
        {
            int mid = (l + h) / 2;
            if (arr[mid] >= x)
                h = mid - 1;
            else
                l = mid + 1;
        }
        return l;
    }

    // function to find last index <= y
    static int upperIndex(int arr[], int n, int y) {
        int l = 0, h = n - 1;
        while (l <= h)
        {
            int mid = (l + h) / 2;
            if (arr[mid] <= y)
                l = mid + 1;
            else
                h = mid - 1;
        }
        return h;
    }

    public static StringBuilder dec_to_bin(long n) {
        // decimal to binary upto 30 binaries
        if(n==0) {
            StringBuilder str=new StringBuilder("");
            for(int i=0;i<30;i++) {
                str.append("0");
            }
            return str;
        }
        StringBuilder str=new StringBuilder("");
        while(n!=0) {
            str.append(n%2L);
            n/=2L;
        }
        str=str.reverse();
        StringBuilder tmp_str=new StringBuilder("");
        int len=str.length();
        while(len!=30) {
            tmp_str.append("0");
            len++;
        }
        tmp_str.append(str);
        return tmp_str;
    }

    private static int binarySearchPM(int[] arr, int key){
        int n = arr.length;
        int mid = -1;
        int begin = 0,end=n;
        while(begin <= end){
            mid = (begin+end) / 2;
            if(mid == n){
                return n;
            }
            if(key < arr[mid]){
                end = mid-1;
            } else if(key > arr[mid]){
                begin = mid+1;
            } else {
                return mid;
            }
        }
        //System.out.println(begin+" "+end);
        return -begin; //expected Index
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
}


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

public class Main {

    static class Pair {
        int a, b;
        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
        public String toString() {
            return a+" "+b;
        }
    }

    static HashMap<Integer, Integer> hm = new HashMap<>();

    public static void main(String[] args) throws java.lang.Exception {
        Reader pm =new Reader();
        //Scanner pm = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int t = pm.nextInt();
        while(t-- > 0){
            int n = pm.nextInt();
            hm = new HashMap<>();
            printFac(n);

            if(hm.size() >= 3) {
                System.out.println("YES");
                ArrayList<Long> al = new ArrayList<>();
                int ind = 0;
                for(int i:hm.keySet()) {
                    if(al.size() != 3)
                        al.add((long)Math.pow(i, hm.get(i)));
                    else {
                        al.set(ind, al.get(ind) * (long)Math.pow(i, hm.get(i)));
                        ind++;
                        if(ind == al.size())
                            ind = 0;
                    }
                }
                System.out.println(al.get(0)+" "+al.get(1)+" "+al.get(2));
            }
            else if(hm.size() == 2) {
                //System.out.println("YES");

                ArrayList<Integer> al = new ArrayList<>();
                for(int i:hm.keySet()) {
                    al.add(hm.get(i));
                }
                Collections.sort(al);
                int a = al.get(1);
                int b = al.get(0);
                int max = -1;
                int min = -1;

                for(int i:hm.keySet()) {
                    if(hm.get(i) == a) {
                        max = i;
                    }
                    else {
                        min = i;
                    }
                }

                int fl = 0;
                if(a < 3) {
                    fl = 1;
                }
                if(fl == 1) {
                    System.out.println("NO");
                } else {
                    System.out.println("YES");
                    long op1 = (long) Math.pow(max, 1);
                    long op2 = (long) Math.pow(max, a-1);
                    long op3 = (long) Math.pow(min, b);
                    System.out.println(op1+" "+op2+" "+op3);
                }
                // int ind = 0;

                // for(int i:hm.keySet()) {
                //     int pow = hm.get(i);
                //     int now = 1;

                //     while(pow-now >= 0) {

                //         al.add(new Pair(now, i));
                //         pow -= now;
                //         now++;
                //         if(now > pow && pow > 0) {
                //             al.add(new Pair(pow, i));
                //         }
                //     }
                // }
                // System.out.println(hm+" "+al);
                // //Collections.sort(al);
                // if(al.size() < 3) {
                //     System.out.println("NO");
                // }
                // else {

                //     ArrayList<Long> ans = new ArrayList<>();

                //     for(int i=0;i<al.size();i++) {
                //         if(ans.size() < 3) {
                //             ans.add((long)Math.pow(al.get(i).b, al.get(i).a));
                //         } else {
                //             ans.set(ind, (ans.get(ind) * ((long)Math.pow(al.get(i).b, al.get(i).a))));
                //             ind++;
                //             if(ind == ans.size())
                //             ind = 0;
                //         }
                //     }
                //     int fl = 0;
                //     HashSet<Long> hs = new HashSet<>();
                //     for(int i=0;i<ans.size();i++) {
                //         if(hs.contains(ans.get(i))) {
                //             fl = 1;
                //             break;
                //         }
                //         hs.add(ans.get(i));

                //     }
                //     System.out.println(ans);

                //     if(fl == 1) {
                //         System.out.println("NO");
                //     }
                //     else {
                //         System.out.println("YES");
                //         System.out.println(ans.get(0)+" "+ans.get(1)+" "+ans.get(2));
                //     }

                // }
            }
            else if(hm.size() == 1) {
                ArrayList<Integer> al = new ArrayList<>();
                int ele = -1;
                for(int i:hm.keySet()) {
                    ele = i;
                }
                int pow = hm.get(ele);
                if(pow < 6) {
                    System.out.println("NO");
                } else {
                    System.out.println("YES");
                    long op1 = (long) Math.pow(ele, 1);
                    long op2 = (long) Math.pow(ele, 2);
                    long op3 = (long) Math.pow(ele, pow - 3);
                    System.out.println(op1+" "+op2+" "+op3);
                }
            }
            else {
                System.out.println("NO");
            }

        }
        //end of tests

    }
    //end of main class
    static void printFac(int n) {
        while(n % 2 == 0) {
            hm.merge(2,1,Integer::sum);
            n/=2;
        }
        for(int i=3;i<=Math.sqrt(n);i+=2) {
            if(n % i == 0) {
                n/=i;
                hm.merge(i,1, Integer::sum);
            }
        }
        if(n >  2) {
            hm.merge(n,1, Integer::sum);
        }
    }
    static int countInRange(int arr[], int n, int x, int y) {
        // initialize result
        int count = 0;
        count = upperIndex(arr, n, y) -
                lowerIndex(arr, n, x) + 1;
        return count;
    }

    static int lowerIndex(int arr[], int n, int x) {
        int l = 0, h = n - 1;
        while (l <= h)
        {
            int mid = (l + h) / 2;
            if (arr[mid] >= x)
                h = mid - 1;
            else
                l = mid + 1;
        }
        return l;
    }

    // function to find last index <= y
    static int upperIndex(int arr[], int n, int y) {
        int l = 0, h = n - 1;
        while (l <= h)
        {
            int mid = (l + h) / 2;
            if (arr[mid] <= y)
                l = mid + 1;
            else
                h = mid - 1;
        }
        return h;
    }

    public static StringBuilder dec_to_bin(long n) {
        // decimal to binary upto 30 binaries
        if(n==0) {
            StringBuilder str=new StringBuilder("");
            for(int i=0;i<30;i++) {
                str.append("0");
            }
            return str;
        }
        StringBuilder str=new StringBuilder("");
        while(n!=0) {
            str.append(n%2L);
            n/=2L;
        }
        str=str.reverse();
        StringBuilder tmp_str=new StringBuilder("");
        int len=str.length();
        while(len!=30) {
            tmp_str.append("0");
            len++;
        }
        tmp_str.append(str);
        return tmp_str;
    }

    private static int binarySearchPM(int[] arr, int key){
        int n = arr.length;
        int mid = -1;
        int begin = 0,end=n;
        while(begin <= end){
            mid = (begin+end) / 2;
            if(mid == n){
                return n;
            }
            if(key < arr[mid]){
                end = mid-1;
            } else if(key > arr[mid]){
                begin = mid+1;
            } else {
                return mid;
            }
        }
        //System.out.println(begin+" "+end);
        return -begin; //expected Index
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
}


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

public class Main {

    static class Pair {
        int a, b;
        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
        public String toString() {
            return a+" "+b;
        }
    }

    static HashMap<Integer, Integer> hm = new HashMap<>();

    public static void main(String[] args) throws java.lang.Exception {
        Reader pm =new Reader();
        //Scanner pm = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int t = pm.nextInt();
        while(t-- > 0){
            int n = pm.nextInt();
            hm = new HashMap<>();
            printFac(n);

            if(hm.size() >= 3) {
                System.out.println("YES");
                ArrayList<Long> al = new ArrayList<>();
                int ind = 0;
                for(int i:hm.keySet()) {
                    if(al.size() != 3)
                        al.add((long)Math.pow(i, hm.get(i)));
                    else {
                        al.set(ind, al.get(ind) * (long)Math.pow(i, hm.get(i)));
                        ind++;
                        if(ind == al.size())
                            ind = 0;
                    }
                }
                System.out.println(al.get(0)+" "+al.get(1)+" "+al.get(2));
            }
            else if(hm.size() == 2) {
                //System.out.println("YES");

                ArrayList<Integer> al = new ArrayList<>();
                for(int i:hm.keySet()) {
                    al.add(hm.get(i));
                }
                Collections.sort(al);
                int a = al.get(1);
                int b = al.get(0);
                int max = -1;
                int min = -1;
                ArrayList<Integer> put = new ArrayList<>();
                for(int i:hm.keySet()) {

                    if(hm.get(i) == a) {
                        max = i;
                    }
                    else {
                        min = i;
                    }
                    put.add(i);
                }
                if(a == b) {
                    max = put.get(0);
                    min = put.get(1);
                }
                int fl = 0;
                int pow1 = a-1;
                int pow2 = b-1;
                //System.out.println(pow1+" "+pow2+" "+max+" "+min);
                if(pow1 == 0 || pow2 == 0)
                    fl = 1;
                if(fl == 1) {
                    System.out.println("NO");
                } else {
                    System.out.println("YES");
                    long op1 = (long) Math.pow(max, 1);
                    long op2 = (long) Math.pow(max, pow1) * (long) Math.pow(min, pow2);;
                    long op3 = (long) Math.pow(min, 1);
                    System.out.println(op1+" "+op2+" "+op3);
                }
                // int ind = 0;

                // for(int i:hm.keySet()) {
                //     int pow = hm.get(i);
                //     int now = 1;

                //     while(pow-now >= 0) {

                //         al.add(new Pair(now, i));
                //         pow -= now;
                //         now++;
                //         if(now > pow && pow > 0) {
                //             al.add(new Pair(pow, i));
                //         }
                //     }
                // }
                // System.out.println(hm+" "+al);
                // //Collections.sort(al);
                // if(al.size() < 3) {
                //     System.out.println("NO");
                // }
                // else {

                //     ArrayList<Long> ans = new ArrayList<>();

                //     for(int i=0;i<al.size();i++) {
                //         if(ans.size() < 3) {
                //             ans.add((long)Math.pow(al.get(i).b, al.get(i).a));
                //         } else {
                //             ans.set(ind, (ans.get(ind) * ((long)Math.pow(al.get(i).b, al.get(i).a))));
                //             ind++;
                //             if(ind == ans.size())
                //             ind = 0;
                //         }
                //     }
                //     int fl = 0;
                //     HashSet<Long> hs = new HashSet<>();
                //     for(int i=0;i<ans.size();i++) {
                //         if(hs.contains(ans.get(i))) {
                //             fl = 1;
                //             break;
                //         }
                //         hs.add(ans.get(i));

                //     }
                //     System.out.println(ans);

                //     if(fl == 1) {
                //         System.out.println("NO");
                //     }
                //     else {
                //         System.out.println("YES");
                //         System.out.println(ans.get(0)+" "+ans.get(1)+" "+ans.get(2));
                //     }

                // }
            }
            else if(hm.size() == 1) {
                ArrayList<Integer> al = new ArrayList<>();
                int ele = -1;
                for(int i:hm.keySet()) {
                    ele = i;
                }
                int pow = hm.get(ele);
                if(pow < 6) {
                    System.out.println("NO");
                } else {
                    System.out.println("YES");
                    long op1 = (long) Math.pow(ele, 1);
                    long op2 = (long) Math.pow(ele, 2);
                    long op3 = (long) Math.pow(ele, pow - 3);
                    System.out.println(op1+" "+op2+" "+op3);
                }
            }
            else {
                System.out.println("NO");
            }

        }
        //end of tests

    }
    //end of main class
    static void printFac(int n) {
        while(n % 2 == 0) {
            hm.merge(2,1,Integer::sum);
            n/=2;
        }
        for(int i=3;i<=Math.sqrt(n);i+=2) {
            if(n % i == 0) {
                n/=i;
                hm.merge(i,1, Integer::sum);
            }
        }
        if(n >  2) {
            hm.merge(n,1, Integer::sum);
        }
    }
    static int countInRange(int arr[], int n, int x, int y) {
        // initialize result
        int count = 0;
        count = upperIndex(arr, n, y) -
                lowerIndex(arr, n, x) + 1;
        return count;
    }

    static int lowerIndex(int arr[], int n, int x) {
        int l = 0, h = n - 1;
        while (l <= h)
        {
            int mid = (l + h) / 2;
            if (arr[mid] >= x)
                h = mid - 1;
            else
                l = mid + 1;
        }
        return l;
    }

    // function to find last index <= y
    static int upperIndex(int arr[], int n, int y) {
        int l = 0, h = n - 1;
        while (l <= h)
        {
            int mid = (l + h) / 2;
            if (arr[mid] <= y)
                l = mid + 1;
            else
                h = mid - 1;
        }
        return h;
    }

    public static StringBuilder dec_to_bin(long n) {
        // decimal to binary upto 30 binaries
        if(n==0) {
            StringBuilder str=new StringBuilder("");
            for(int i=0;i<30;i++) {
                str.append("0");
            }
            return str;
        }
        StringBuilder str=new StringBuilder("");
        while(n!=0) {
            str.append(n%2L);
            n/=2L;
        }
        str=str.reverse();
        StringBuilder tmp_str=new StringBuilder("");
        int len=str.length();
        while(len!=30) {
            tmp_str.append("0");
            len++;
        }
        tmp_str.append(str);
        return tmp_str;
    }

    private static int binarySearchPM(int[] arr, int key){
        int n = arr.length;
        int mid = -1;
        int begin = 0,end=n;
        while(begin <= end){
            mid = (begin+end) / 2;
            if(mid == n){
                return n;
            }
            if(key < arr[mid]){
                end = mid-1;
            } else if(key > arr[mid]){
                begin = mid+1;
            } else {
                return mid;
            }
        }
        //System.out.println(begin+" "+end);
        return -begin; //expected Index
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
}


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

public class Main {

    static class Pair {
        int a, b;
        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
        public String toString() {
            return a+" "+b;
        }
    }

    static HashMap<Integer, Integer> hm = new HashMap<>();

    public static void main(String[] args) throws java.lang.Exception {
        Reader pm =new Reader();
        //Scanner pm = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int t = pm.nextInt();
        while(t-- > 0){
            int n = pm.nextInt();
            hm = new HashMap<>();
            printFac(n);

            if(hm.size() >= 3) {
                System.out.println("YES");
                ArrayList<Long> al = new ArrayList<>();
                int ind = 0;
                for(int i:hm.keySet()) {
                    if(al.size() != 3)
                        al.add((long)Math.pow(i, hm.get(i)));
                    else {
                        al.set(ind, al.get(ind) * (long)Math.pow(i, hm.get(i)));
                        ind++;
                        if(ind == al.size())
                            ind = 0;
                    }
                }
                System.out.println(al.get(0)+" "+al.get(1)+" "+al.get(2));
            }
            else if(hm.size() == 2) {
                //System.out.println("YES");

                ArrayList<Integer> al = new ArrayList<>();
                for(int i:hm.keySet()) {
                    al.add(hm.get(i));
                }
                Collections.sort(al);
                int a = al.get(1);
                int b = al.get(0);
                int max = -1;
                int min = -1;
                ArrayList<Integer> put = new ArrayList<>();
                for(int i:hm.keySet()) {

                    if(hm.get(i) == a) {
                        max = i;
                    }
                    else {
                        min = i;
                    }
                    put.add(i);
                }
                if(a == b) {
                    max = put.get(0);
                    min = put.get(1);
                }
                int fl = 0;
                int pow1 = a-1;
                int pow2 = b-1;
                //System.out.println(pow1+" "+pow2+" "+max+" "+min);
                if(pow1 == 0 && pow2 == 0)
                    fl = 1;
                if(fl == 1) {
                    System.out.println("NO");
                    continue;
                }
                if(pow2 == 0) {
                    System.out.println("YES");
                    long op1 = (long) Math.pow(max, 1);
                    long op2 = (long) Math.pow(max, pow1);
                    long op3 = (long) Math.pow(min, 1);
                    System.out.println(op1+" "+op2+" "+op3);
                    continue;
                }
                if(pow1 == 0) {
                    System.out.println("YES");
                    long op1 = (long) Math.pow(max, 1);
                    long op2 = (long) Math.pow(min, pow2);
                    long op3 = (long) Math.pow(min, 1);
                    System.out.println(op1+" "+op2+" "+op3);
                    continue;
                }
                if(fl == 1) {
                    System.out.println("NO");
                } else {
                    System.out.println("YES");
                    long op1 = (long) Math.pow(max, 1);
                    long op2 = (long) Math.pow(max, pow1) * (long) Math.pow(min, pow2);;
                    long op3 = (long) Math.pow(min, 1);
                    System.out.println(op1+" "+op2+" "+op3);
                }
                // int ind = 0;

                // for(int i:hm.keySet()) {
                //     int pow = hm.get(i);
                //     int now = 1;

                //     while(pow-now >= 0) {

                //         al.add(new Pair(now, i));
                //         pow -= now;
                //         now++;
                //         if(now > pow && pow > 0) {
                //             al.add(new Pair(pow, i));
                //         }
                //     }
                // }
                // System.out.println(hm+" "+al);
                // //Collections.sort(al);
                // if(al.size() < 3) {
                //     System.out.println("NO");
                // }
                // else {

                //     ArrayList<Long> ans = new ArrayList<>();

                //     for(int i=0;i<al.size();i++) {
                //         if(ans.size() < 3) {
                //             ans.add((long)Math.pow(al.get(i).b, al.get(i).a));
                //         } else {
                //             ans.set(ind, (ans.get(ind) * ((long)Math.pow(al.get(i).b, al.get(i).a))));
                //             ind++;
                //             if(ind == ans.size())
                //             ind = 0;
                //         }
                //     }
                //     int fl = 0;
                //     HashSet<Long> hs = new HashSet<>();
                //     for(int i=0;i<ans.size();i++) {
                //         if(hs.contains(ans.get(i))) {
                //             fl = 1;
                //             break;
                //         }
                //         hs.add(ans.get(i));

                //     }
                //     System.out.println(ans);

                //     if(fl == 1) {
                //         System.out.println("NO");
                //     }
                //     else {
                //         System.out.println("YES");
                //         System.out.println(ans.get(0)+" "+ans.get(1)+" "+ans.get(2));
                //     }

                // }
            }
            else if(hm.size() == 1) {
                ArrayList<Integer> al = new ArrayList<>();
                int ele = -1;
                for(int i:hm.keySet()) {
                    ele = i;
                }
                int pow = hm.get(ele);
                if(pow < 6) {
                    System.out.println("NO");
                } else {
                    System.out.println("YES");
                    long op1 = (long) Math.pow(ele, 1);
                    long op2 = (long) Math.pow(ele, 2);
                    long op3 = (long) Math.pow(ele, pow - 3);
                    System.out.println(op1+" "+op2+" "+op3);
                }
            }
            else {
                System.out.println("NO");
            }

        }
        //end of tests

    }
    //end of main class
    static void printFac(int n) {
        while(n % 2 == 0) {
            hm.merge(2,1,Integer::sum);
            n/=2;
        }
        for(int i=3;i<=Math.sqrt(n);i+=2) {
            if(n % i == 0) {
                n/=i;
                hm.merge(i,1, Integer::sum);
            }
        }
        if(n >  2) {
            hm.merge(n,1, Integer::sum);
        }
    }
    static int countInRange(int arr[], int n, int x, int y) {
        // initialize result
        int count = 0;
        count = upperIndex(arr, n, y) -
                lowerIndex(arr, n, x) + 1;
        return count;
    }

    static int lowerIndex(int arr[], int n, int x) {
        int l = 0, h = n - 1;
        while (l <= h)
        {
            int mid = (l + h) / 2;
            if (arr[mid] >= x)
                h = mid - 1;
            else
                l = mid + 1;
        }
        return l;
    }

    // function to find last index <= y
    static int upperIndex(int arr[], int n, int y) {
        int l = 0, h = n - 1;
        while (l <= h)
        {
            int mid = (l + h) / 2;
            if (arr[mid] <= y)
                l = mid + 1;
            else
                h = mid - 1;
        }
        return h;
    }

    public static StringBuilder dec_to_bin(long n) {
        // decimal to binary upto 30 binaries
        if(n==0) {
            StringBuilder str=new StringBuilder("");
            for(int i=0;i<30;i++) {
                str.append("0");
            }
            return str;
        }
        StringBuilder str=new StringBuilder("");
        while(n!=0) {
            str.append(n%2L);
            n/=2L;
        }
        str=str.reverse();
        StringBuilder tmp_str=new StringBuilder("");
        int len=str.length();
        while(len!=30) {
            tmp_str.append("0");
            len++;
        }
        tmp_str.append(str);
        return tmp_str;
    }

    private static int binarySearchPM(int[] arr, int key){
        int n = arr.length;
        int mid = -1;
        int begin = 0,end=n;
        while(begin <= end){
            mid = (begin+end) / 2;
            if(mid == n){
                return n;
            }
            if(key < arr[mid]){
                end = mid-1;
            } else if(key > arr[mid]){
                begin = mid+1;
            } else {
                return mid;
            }
        }
        //System.out.println(begin+" "+end);
        return -begin; //expected Index
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
}


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

public class Main {

    static class Pair {
        int a, b;
        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
        public String toString() {
            return a+" "+b;
        }
    }

    static HashMap<Integer, Integer> hm = new HashMap<>();

    public static void main(String[] args) throws java.lang.Exception {
        Reader pm =new Reader();
        //Scanner pm = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int t = pm.nextInt();
        while(t-- > 0){
            int n = pm.nextInt();
            hm = new HashMap<>();
            printFac(n);

            if(hm.size() >= 3) {
                System.out.println("YES");
                ArrayList<Long> al = new ArrayList<>();
                int ind = 0;
                for(int i:hm.keySet()) {
                    if(al.size() != 3)
                        al.add((long)Math.pow(i, hm.get(i)));
                    else {
                        al.set(ind, al.get(ind) * (long)Math.pow(i, hm.get(i)));
                        ind++;
                        if(ind == al.size())
                            ind = 0;
                    }
                }
                System.out.println(al.get(0)+" "+al.get(1)+" "+al.get(2));
            }
            else if(hm.size() == 2) {
                //System.out.println("YES");

                ArrayList<Integer> al = new ArrayList<>();
                for(int i:hm.keySet()) {
                    al.add(hm.get(i));
                }
                Collections.sort(al);
                int a = al.get(1);
                int b = al.get(0);
                int max = -1;
                int min = -1;
                ArrayList<Integer> put = new ArrayList<>();
                for(int i:hm.keySet()) {

                    if(hm.get(i) == a) {
                        max = i;
                    }
                    else {
                        min = i;
                    }
                    put.add(i);
                }
                if(a == b) {
                    max = put.get(0);
                    min = put.get(1);
                }
                int fl = 0;
                int pow1 = a-1;
                int pow2 = b-1;
                //System.out.println(pow1+" "+pow2+" "+max+" "+min);
                if(pow1 == 0 && pow2 == 0)
                    fl = 1;
                if(pow2 == 0) {
                    System.out.println("YES");
                    long op1 = (long) Math.pow(max, 1);
                    long op2 = (long) Math.pow(max, pow1);
                    long op3 = (long) Math.pow(min, 1);
                    System.out.println(op1+" "+op2+" "+op3);
                    continue;
                }
                if(pow1 == 0) {
                    System.out.println("YES");
                    long op1 = (long) Math.pow(max, 1);
                    long op2 = (long) Math.pow(min, pow2);
                    long op3 = (long) Math.pow(min, 1);
                    System.out.println(op1+" "+op2+" "+op3);
                    continue;
                }
                if(fl == 1) {
                    System.out.println("NO");
                } else {
                    System.out.println("YES");
                    long op1 = (long) Math.pow(max, 1);
                    long op2 = (long) Math.pow(max, pow1) * (long) Math.pow(min, pow2);;
                    long op3 = (long) Math.pow(min, 1);
                    System.out.println(op1+" "+op2+" "+op3);
                }
                // int ind = 0;

                // for(int i:hm.keySet()) {
                //     int pow = hm.get(i);
                //     int now = 1;

                //     while(pow-now >= 0) {

                //         al.add(new Pair(now, i));
                //         pow -= now;
                //         now++;
                //         if(now > pow && pow > 0) {
                //             al.add(new Pair(pow, i));
                //         }
                //     }
                // }
                // System.out.println(hm+" "+al);
                // //Collections.sort(al);
                // if(al.size() < 3) {
                //     System.out.println("NO");
                // }
                // else {

                //     ArrayList<Long> ans = new ArrayList<>();

                //     for(int i=0;i<al.size();i++) {
                //         if(ans.size() < 3) {
                //             ans.add((long)Math.pow(al.get(i).b, al.get(i).a));
                //         } else {
                //             ans.set(ind, (ans.get(ind) * ((long)Math.pow(al.get(i).b, al.get(i).a))));
                //             ind++;
                //             if(ind == ans.size())
                //             ind = 0;
                //         }
                //     }
                //     int fl = 0;
                //     HashSet<Long> hs = new HashSet<>();
                //     for(int i=0;i<ans.size();i++) {
                //         if(hs.contains(ans.get(i))) {
                //             fl = 1;
                //             break;
                //         }
                //         hs.add(ans.get(i));

                //     }
                //     System.out.println(ans);

                //     if(fl == 1) {
                //         System.out.println("NO");
                //     }
                //     else {
                //         System.out.println("YES");
                //         System.out.println(ans.get(0)+" "+ans.get(1)+" "+ans.get(2));
                //     }

                // }
            }
            else if(hm.size() == 1) {
                ArrayList<Integer> al = new ArrayList<>();
                int ele = -1;
                for(int i:hm.keySet()) {
                    ele = i;
                }
                int pow = hm.get(ele);
                if(pow < 6) {
                    System.out.println("NO");
                } else {
                    System.out.println("YES");
                    long op1 = (long) Math.pow(ele, 1);
                    long op2 = (long) Math.pow(ele, 2);
                    long op3 = (long) Math.pow(ele, pow - 3);
                    System.out.println(op1+" "+op2+" "+op3);
                }
            }
            else {
                System.out.println("NO");
            }

        }
        //end of tests

    }
    //end of main class
    static void printFac(int n) {
        while(n % 2 == 0) {
            hm.merge(2,1,Integer::sum);
            n/=2;
        }
        for(int i=3;i<=Math.sqrt(n);i+=2) {
            if(n % i == 0) {
                n/=i;
                hm.merge(i,1, Integer::sum);
            }
        }
        if(n >  2) {
            hm.merge(n,1, Integer::sum);
        }
    }
    static int countInRange(int arr[], int n, int x, int y) {
        // initialize result
        int count = 0;
        count = upperIndex(arr, n, y) -
                lowerIndex(arr, n, x) + 1;
        return count;
    }

    static int lowerIndex(int arr[], int n, int x) {
        int l = 0, h = n - 1;
        while (l <= h)
        {
            int mid = (l + h) / 2;
            if (arr[mid] >= x)
                h = mid - 1;
            else
                l = mid + 1;
        }
        return l;
    }

    // function to find last index <= y
    static int upperIndex(int arr[], int n, int y) {
        int l = 0, h = n - 1;
        while (l <= h)
        {
            int mid = (l + h) / 2;
            if (arr[mid] <= y)
                l = mid + 1;
            else
                h = mid - 1;
        }
        return h;
    }

    public static StringBuilder dec_to_bin(long n) {
        // decimal to binary upto 30 binaries
        if(n==0) {
            StringBuilder str=new StringBuilder("");
            for(int i=0;i<30;i++) {
                str.append("0");
            }
            return str;
        }
        StringBuilder str=new StringBuilder("");
        while(n!=0) {
            str.append(n%2L);
            n/=2L;
        }
        str=str.reverse();
        StringBuilder tmp_str=new StringBuilder("");
        int len=str.length();
        while(len!=30) {
            tmp_str.append("0");
            len++;
        }
        tmp_str.append(str);
        return tmp_str;
    }

    private static int binarySearchPM(int[] arr, int key){
        int n = arr.length;
        int mid = -1;
        int begin = 0,end=n;
        while(begin <= end){
            mid = (begin+end) / 2;
            if(mid == n){
                return n;
            }
            if(key < arr[mid]){
                end = mid-1;
            } else if(key > arr[mid]){
                begin = mid+1;
            } else {
                return mid;
            }
        }
        //System.out.println(begin+" "+end);
        return -begin; //expected Index
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
}


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);
			ArrayList<Long> ans = new ArrayList<Long>();
			for(int j=0;j<list.size();j++)
			{
				if(ans.size()>=3)
					break;
				Pair p = list.get(j);
				for(int k=1;k<=3;k++)
				{
					if(p.get(1)<k)
						break;
					p.b-=k; ans.add((long)Math.pow((long)p.get(0),k));
				}
				if(p.b>=1 && j-1>=0 && ((list.get(j-1)).get(1)>=1))
				{
					p.b-=1;
					ans.add((long)p.a*(list.get(j-1)).get(0));
				}
			}
			long val=1;
			if(ans.size()<3)
			{
				out.println("NO");
				continue;
			}
			out.println("YES");
			for(int k=0;k<3;k++)
			{
				val*=ans.get(k);
				if(k==2)
				{
					out.println(ans.get(k)*(n/val)); continue;
				}
				out.print(ans.get(k)+" ");
			}
		}
		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();
			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");
				int p1,p2,p3;
				p1 = (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)>=3)
				{
					out.println("YES");
					int v1 = p1.get(0);
					int v2 = v1*v1;
					out.println(v1+" "+v2+" ");
					out.println(p2.get(0));
				}
				else if(p2.get(1)>=3)
				{
					out.println("YES");
					int v1 = p2.get(0);
					int v2 = v1*v1;
					out.println(v1+" "+v2+" ");
					out.println(p1.get(0));
				}
				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");
				int p1,p2,p3;
				p1 = (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");
					int v1 = p1.get(0);
					int v2 = 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.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");
				int p1,p2,p3;
				p1 = (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");
					int v1 = p1.get(0);
					int v2 = 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.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;
					if(p1.get(1)==1)
					{
						v3 = v2*v2;
					}
					else if(p2.get(1)==1)
					{
						v3=v1*v1;
					}
					else
						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());
		}
	}
}