#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll t,n,cnt;
int isPrime(int n)
{
    //返回1表示判断为质数，0为非质数，在此没有进行输入异常检测
    float n_sqrt;
    if(n==2 || n==3)
        return 1;
    if(n%6!=1 && n%6!=5)
        return 0;
    n_sqrt=floor(sqrt((float)n));
    for(int i=5; i<=n_sqrt; i+=6)
    {
        if(n%(i)==0 | n%(i+2)==0)
            return 0;
    }
    return 1;
}
int main()
{
    //IOS;
    cin>>t;
    while(t--)
    {
        cin>>n;
        if(isPrime(n))
        {
            cout<<"NO"<<endl;
        }
        else
        {
            cout<<"YES"<<endl;
            cnt=2;
            while(1)
            {
                if(n%cnt==0)
                {
                    break;
                }
                cnt++;
            }
            cout<<1<<' '<<cnt<<' '<<n/cnt<<endl;
        }
    }
    return 0;
}
/*
5
64
32
97
2
12345

*/


#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll t,n,a,b;
int main()
{
    //IOS;
    cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i=2;i*i<=n;i++)
        {
            if(n%i==0)
            {
                a=i;
            }
        }
        if(n%a!=0)
        {
            cout<<"NO"<<endl;
            continue;
        }
        n/=a;
        for(int i=a+1;i*i<=n;i++)
        {
            if(n%i==0)
            {
                b=i;
            }
        }
        if(n%b!=0)
        {
            cout<<"NO"<<endl;
            continue;
        }
        n/=a;
        if(a!=n&&b!=n&&n!=1)
        {
            cout<<a<<' '<<b<<' '<<n<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
            continue;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll t;
ll n,a,b;
int main()
{
    //IOS;
    cin>>t;
    while(t--)
    {
        cin>>n;
        a=0;
        b=0;
        for(int i=2;i*i<=n;i++)
        {
            if(n%i==0)
            {
                a=i;
                break;
            }
        }
        if(a==0)
        {
            cout<<"NO"<<endl;
            continue;
        }
        n/=a;
        for(int i=a+1;i*i<=n;i++)
        {
            if(n%i==0)
            {
                b=i;
                break;
            }
        }
        if(b==0)
        {
            cout<<"NO"<<endl;
            continue;
        }
        n/=b;
        if(a!=n&&b!=n&&n!=1)
        {
            cout<<a<<' '<<b<<' '<<n<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
            continue;
        }
    }
    return 0;
}
/*
5
64
32
97
2
12345

*/


#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll t,n,a,b;
int isPrime(int n)
{
    //返回1表示判断为质数，0为非质数，在此没有进行输入异常检测
    float n_sqrt;
    if(n==2 || n==3)
        return 1;
    if(n%6!=1 && n%6!=5)
        return 0;
    n_sqrt=floor(sqrt((float)n));
    for(int i=5; i<=n_sqrt; i+=6)
    {
        if(n%(i)==0 | n%(i+2)==0)
            return 0;
    }
    return 1;
}
int main()
{
    //IOS;
    cin>>t;
    while(t--)
    {
        cin>>n;
        if(isPrime(n))
        {
            cout<<"NO"<<endl;
        }
        else
        {
            ll cnt=2;
            while(1)
            {
                if(n%cnt==0)
                {
                    n/=cnt;
                    a=cnt;
                    cnt++;
                    break;
                }
                cnt++;
            }
            if(isPrime(n))
            {
                cout<<"NO"<<endl;
                continue;
            }
            while(1)
            {
                if(n%cnt==0)
                {
                    n/=cnt;
                    b=cnt;
                    break;
                }
                cnt++;
            }
            if(n>b)
            {
                cout<<"YES"<<endl;
                cout<<a<<' '<<b<<' '<<n<<endl;
            }
            else
                cout<<"NO"<<endl;
        }
    }
    return 0;
}
/*
5
64
32
97
2
12345

*/


#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll t,n,a,b,c,flag,cnt;
int isPrime(int n)
{
    //返回1表示判断为质数，0为非质数，在此没有进行输入异常检测
    float n_sqrt;
    if(n==2 || n==3)
        return 1;
    if(n%6!=1 && n%6!=5)
        return 0;
    n_sqrt=floor(sqrt((float)n));
    for(int i=5; i<=n_sqrt; i+=6)
    {
        if(n%(i)==0 | n%(i+2)==0)
            return 0;
    }
    return 1;
}
int main()
{
    //IOS;
    cin>>t;
    while(t--)
    {
        cin>>n;
        flag=0;
        cnt=2;
        if(isPrime(n)||n<24)
        {
            cout<<"NO"<<endl;
        }
        else
        {
            while(1)
            {
                if(cnt>=n)
                {
                    break;
                }
                if(n%cnt==0)
                {
                    if(flag==0&&n%cnt==0)
                    {
                        a=cnt;
                        n/=cnt;
                        flag=1;
                        cnt++;
                        if(isPrime(n))
                        {
                            cout<<"NO"<<endl;
                            goto s1;
                        }
                    }
                    if(flag==1&&n%cnt==0)
                    {
                        b=cnt;
                        n/=cnt;
                        cout<<cnt<<endl;
                        break;
                    }
                }
                else
                {
                    cnt++;
                }
            }
            if(n>b&&b!=0)
            {
                cout<<"YES"<<endl;
                cout<<min(a,b)<<' '<<max(a,b)<<' '<<n<<endl;
            }
            else
                cout<<"NO"<<endl;
            s1:;
        }
    }
    return 0;
}
/*
5
64
32
97
2
12345

*/


#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll t,n,a,b;
int isPrime(int n)
{
    //返回1表示判断为质数，0为非质数，在此没有进行输入异常检测
    float n_sqrt;
    if(n==2 || n==3)
        return 1;
    if(n%6!=1 && n%6!=5)
        return 0;
    n_sqrt=floor(sqrt((float)n));
    for(int i=5; i<=n_sqrt; i+=6)
    {
        if(n%(i)==0 | n%(i+2)==0)
            return 0;
    }
    return 1;
}
int main()
{
    //IOS;
    cin>>t;
    while(t--)
    {
        cin>>n;
        if(isPrime(n))
        {
            cout<<"NO"<<endl;
        }
        else
        {
            ll cnt=2;
            while(1)
            {
                if(n%cnt==0)
                {
                    n/=cnt;
                    a=cnt;
                    cnt++;
                    break;
                }
                cnt++;
            }
            if(isPrime(n))
            {
                cout<<"NO"<<endl;
                continue;
            }
            ll cnt=2;
            while(1)
            {
                if(n%cnt==0)
                {
                    n/=cnt;
                    b=cnt;
                    break;
                }
                cnt++;
            }
            if(n>b)
            {
                cout<<"YES"<<endl;
                cout<<a<<' '<<b<<' '<<n<<endl;
            }
            else
                cout<<"NO"<<endl;
        }
    }
    return 0;
}
/*
5
64
32
97
2
12345

*/


#include <iostream>
#include <vector>

using namespace std;

typedef long long int lli;

int main(){

    lli t;
    cin>>t;
    vector<lli> vec(100000,0), primes;
    for(lli i(2); i<=100000; i++){
        if(vec[i]==0){
            primes.push_back(i);
            for(lli j(i*2); j<=100000; j+=i){
                vec[j] = 1;
            }
        }
    }
    for(lli j(0); j<t; j++){
        lli n;
        cin>>n;
        lli a(0), b(0), c(0);
        lli m(n);
        bool flag(true);
        for(lli i(0); flag and i < primes.size() and primes[i]<m; i++){
            if(c){
                break;
            }
            if(n%primes[i]==0){
                if(a==0){
                    a=primes[i];
                }
                else if(b==0){
                    b=primes[i];
                    if(n/b!=a and n/b!=b and n/b>2){
                        c = n/b;
                    }
                    break;
                }
                else if(c==0){
                    if(n/primes[i]==1){
                        c = primes[i];
                        break;
                    }
                    else
                        n*=primes[i];
                }
                else{
                    break;
                }
                n/=primes[i];
                //cout<<n*primes[i]<<"/"<<primes[i]<<" = "<<n<<endl;
                lli mult{primes[i]*2};
                lli q(n);
                while(mult <= q and q%mult==0){
                    if(b==0){
                        b = mult;
                        n=q/mult;
                    }
                    else if(c==0){
                        if(q/mult==1){
                            c=mult;
                            n=q/mult;
                        }
                        else{
                            c=q;
                        }
                    }
                    else{
                        flag = false;
                        break;
                    }
                    q/=mult;
                    mult*=primes[i];
                    //cout<<n*mult<<"/"<<mult<<" = "<<n<<endl;
                }
            }
        }
        //cout<<a<<" "<<b<<" "<<c<<endl;
        if(c!=0){
            cout<<"YES"<<"\n";
            cout<<a<<" "<<b<<" "<<c<<"\n";
        }
        else{
            cout<<"NO"<<"\n";
        }
    }
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

typedef long long int lli;

int main(){

    lli t;
    cin>>t;
    vector<lli> vec(100000,0), primes;
    for(lli i(2); i<=100000; i++){
        if(vec[i]==0){
            primes.push_back(i);
            for(lli j(i*2); j<=100000; j+=i){
                vec[j] = 1;
            }
        }
    }
    for(lli j(0); j<t; j++){
        lli n;
        cin>>n;
        lli a(0), b(0), c(0);
        lli m(n);
        bool flag(true);
        for(lli i(0); flag and i < primes.size() and primes[i]<m; i++){
            if(c){
                break;
            }
            if(n%primes[i]==0){
                if(a==0){
                    a=primes[i];
                }
                else if(b==0){
                    b=primes[i];
                    if(n/b!=a and n/b!=b and n/b>2){
                        c = n/b;
                    }
                    break;
                }
                else{
                    break;
                }
                n/=primes[i];
                //cout<<n*primes[i]<<"/"<<primes[i]<<" = "<<n<<endl;
                lli mult{primes[i]*2};
                lli q(n);
                while(mult <= q and q%mult==0){
                    if(b==0){
                        b = mult;
                        if(n/b!=a and n/b!=b and n/b>2){
                            c = n/b;
                        }
                        flag = false;
                        break;
                    }
                    else{
                        flag = false;
                        break;
                    }
                    q/=mult;
                    mult*=primes[i];
                    //cout<<n*mult<<"/"<<mult<<" = "<<n<<endl;
                }
            }
        }
        //cout<<a<<" "<<b<<" "<<c<<endl;
        if(c!=0){
            cout<<"YES"<<"\n";
            cout<<a<<" "<<b<<" "<<c<<"\n";
        }
        else{
            cout<<"NO"<<"\n";
        }
    }
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

typedef long long int lli;

int main(){

    lli t;
    cin>>t;
    vector<lli> vec(100000,0), primes;
    for(lli i(2); i<=100000; i++){
        if(vec[i]==0){
            primes.push_back(i);
            for(lli j(i*2); j<=100000; j+=i){
                vec[j] = 1;
            }
        }
    }
    for(lli j(0); j<t; j++){
        lli n;
        cin>>n;
        lli a(0), b(0), c(0);
        lli m(n);
        bool flag(true);
        for(lli i(0); flag and i < primes.size() and primes[i]<m; i++){
            if(c){
                break;
            }
            if(n%primes[i]==0){
                if(a==0){
                    a=primes[i];
                }
                else if(b==0){
                    b=primes[i];
                    if(n/b!=a and n/b!=b){
                        c = n/b;
                    }
                    break;
                }
                else if(c==0){
                    if(n/primes[i]==1){
                        c = primes[i];
                        break;
                    }
                    else
                        n*=primes[i];
                }
                else{
                    break;
                }
                n/=primes[i];
                //cout<<n*primes[i]<<"/"<<primes[i]<<" = "<<n<<endl;
                lli mult{primes[i]*2};
                lli q(n);
                while(mult <= q and q%mult==0){
                    if(b==0){
                        b = mult;
                        n=q/mult;
                    }
                    else if(c==0){
                        if(q/mult==1){
                            c=mult;
                            n=q/mult;
                        }
                        else{
                            c=q;
                        }
                    }
                    else{
                        flag = false;
                        break;
                    }
                    q/=mult;
                    mult*=primes[i];
                    //cout<<n*mult<<"/"<<mult<<" = "<<n<<endl;
                }
            }
        }
        //cout<<a<<" "<<b<<" "<<c<<endl;
        if(c!=0){
            cout<<"YES"<<"\n";
            cout<<a<<" "<<b<<" "<<c<<"\n";
        }
        else{
            cout<<"NO"<<"\n";
        }
    }
    return 0;
}


#include <iostream>

using namespace std;

typedef long long int lli;

int main(){
    lli t;
    cin>>t;
    for(lli j(0); j<t; j++){
        lli n;
        cin>>n;
        lli a(0), b(0), c(0);
        lli m(n);
        for(lli i(2); i<m/5; i++){
            if(c){
                break;
            }
            if(n%i==0){
                if(a==0){
                    a=i;
                }
                else if(b==0){
                    b=i;
                }
                else if(c==0){
                    if(n/i==1){
                        c=i;
                    }
                    else
                        n*=i;
                }
                n/=i;
            }
        }
        if(c!=0){
            cout<<"YES"<<"\n";
            cout<<a<<" "<<b<<" "<<c<<"\n";
        }
        else{
            cout<<"NO"<<"\n";
        }
    }
    return 0;
}


#include <iostream>

using namespace std;

typedef long long int lli;

int main(){
    lli t;
    cin>>t;
    for(int j(0); j<t; j++){
        lli n;
        cin>>n;
        lli a(0), b(0), c(0);
        lli m(n);
        for(int i(2); i<m/2; i++){
            if(c){
                break;
            }
            if(n%i==0){
                if(a==0){
                    a=i;
                }
                else if(b==0){
                    b=i;
                    if(n/b!=b){
                        c = n/b;
                        break;
                    }
                }
                else if(c==0){
                    c=i;
                    break;
                }
                n/=i;
            }
        }
        if(c!=0){
            cout<<"YES"<<"\n";
            cout<<a<<" "<<b<<" "<<c<<"\n";
        }
        else{
            cout<<"NO"<<"\n";
        }
    }
    return 0;
}


#include <iostream>

using namespace std;

typedef long long int lli;

int main(){
    lli t;
    cin>>t;
    for(int j(0); j<t; j++){
        lli n;
        cin>>n;
        lli a(0), b(0), c(0);
        lli m(n);
        for(int i(2); i<m/5; i++){
            if(c){
                break;
            }
            if(n%i==0){
                if(a==0){
                    a=i;
                }
                else if(b==0){
                    b=i;
                }
                else if(c==0){
                    c=i;
                }
                //i=2;
                n/=i;
            }
        }
        if(c!=0){
            cout<<"YES"<<"\n";
            cout<<a<<" "<<b<<" "<<c<<"\n";
        }
        else{
            cout<<"NO"<<"\n";
        }
    }
    return 0;
}


#include <iostream>

using namespace std;

typedef long long int lli;

int main(){
    lli t;
    cin>>t;
    for(int j(0); j<t; j++){
        lli n;
        cin>>n;
        lli a(0), b(0), c(0);
        lli m(n);
        for(int i(2); i<m/2; i++){
            if(c){
                break;
            }
            if(n%i==0){
                if(a==0){
                    a=i;
                }
                else if(b==0){
                    b=i;
                }
                else if(c==0){
                    c=i;
                }
                //i=2;
                n/=i;
            }
        }
        if(c!=0){
            cout<<"YES"<<"\n";
            cout<<a<<" "<<b<<" "<<c<<"\n";
        }
        else{
            cout<<"NO"<<"\n";
        }
    }
    return 0;
}


#include <iostream>

using namespace std;

typedef long long int lli;

int main(){
    lli t;
    cin>>t;
    for(int j(0); j<t; j++){
        lli n;
        cin>>n;
        lli a(0), b(0), c(0);
        lli m(n);
        for(int i(2); i<m/2; i++){
            if(c){
                break;
            }
            if(n%i==0){
                if(a==0){
                    a=i;
                }
                else if(b==0){
                    b=i;
                    if(n/b!=b and n/b!=a){
                        c = n/b;
                        break;
                    }
                }
                else if(c==0){
                    c=i;
                    break;
                }
                n/=i;
            }
        }
        if(c!=0){
            cout<<"YES"<<"\n";
            cout<<a<<" "<<b<<" "<<c<<"\n";
        }
        else{
            cout<<"NO"<<"\n";
        }
    }
    return 0;
}


#include <iostream>

using namespace std;

typedef long long int lli;

int main(){
    lli t;
    cin>>t;
    for(lli j(0); j<t; j++){
        lli n;
        cin>>n;
        lli a(0), b(0), c(0);
        lli m(n);
        for(lli i(2); i<=m/5; i++){
            if(c){
                break;
            }
            if(n%i==0){
                if(a==0){
                    a=i;
                }
                else if(b==0){
                    b=i;
                }
                else if(c==0){
                    if(n/i==1){
                        c=i;
                    }
                    else
                        n*=i;
                }
                n/=i;
            }
        }
        if(c!=0){
            cout<<"YES"<<"\n";
            cout<<a<<" "<<b<<" "<<c<<"\n";
        }
        else{
            cout<<"NO"<<"\n";
        }
    }
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

typedef long long int lli;

int main(){

    lli t;
    cin>>t;
    vector<lli> vec(100000,0), primes;
    for(lli i(2); i<=100000; i++){
        if(vec[i]==0){
            primes.push_back(i);
            for(lli j(i*2); j<=100000; j+=i){
                vec[j] = 1;
            }
        }
    }
    for(lli j(0); j<t; j++){
        lli n;
        cin>>n;
        lli a(0), b(0), c(0);
        lli m(n);
        bool flag(true);
        for(lli i(0); flag and i < primes.size(); i++){
            if(c){
                break;
            }
            if(n%primes[i]==0){
                if(a==0){
                    a=primes[i];
                }
                else if(b==0){
                    b=primes[i];
                }
                else if(c==0){
                    if(n/primes[i]==1){
                        c=primes[i];
                    }
                    else
                        n*=primes[i];
                }
                else{
                    break;
                }
                n/=primes[i];
                lli mult{primes[i]};
                while(n%mult==0){
                    mult*=primes[i];
                    if(b==0){
                        b = mult;
                    }
                    else if(c==0){
                        if(n/mult==1){
                            c=mult;
                        }
                        else{
                            n*=mult;
                        }
                    }
                    else{
                        flag = false;
                        break;
                    }
                    n/=mult;
                }
            }
        }
        if(c!=0){
            cout<<"YES"<<"\n";
            cout<<a<<" "<<b<<" "<<c<<"\n";
        }
        else{
            cout<<"NO"<<"\n";
        }
    }
    return 0;
}


#include <iostream>

using namespace std;

typedef long long int lli;

int main(){
    lli t;
    cin>>t;
    for(int j(0); j<t; j++){
        lli n;
        cin>>n;
        lli a(0), b(0), c(0);
        lli m(n);
        for(int i(2); i<m/2; i++){
            if(c){
                break;
            }
            if(n%i==0){
                if(a==0){
                    a=i;
                }
                else if(b==0){
                    b=i;
                }
                else if(c==0){
                    if(n/i==1){
                        c=i;
                    }
                    else
                        n*=i;
                }
                n/=i;
            }
        }
        if(c!=0){
            cout<<"YES"<<"\n";
            cout<<a<<" "<<b<<" "<<c<<"\n";
        }
        else{
            cout<<"NO"<<"\n";
        }
    }
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

typedef long long int lli;

int main(){

    lli t;
    cin>>t;
    vector<lli> vec(100000,0), primes;
    for(lli i(2); i<=100000; i++){
        if(vec[i]==0){
            primes.push_back(i);
            for(lli j(i*2); j<=100000; j+=i){
                vec[j] = 1;
            }
        }
    }
    for(lli j(0); j<t; j++){
        lli n;
        cin>>n;
        lli a(0), b(0), c(0);
        lli m(n);
        bool flag(true);
        for(lli i(0); flag and i < primes.size() and primes[i]<m; i++){
            if(c){
                break;
            }
            if(n%primes[i]==0){
                if(a==0){
                    a=primes[i];
                }
                else if(b==0){
                    b=primes[i];
                }
                else if(c==0){
                    if(n/primes[i]==1){
                        c = primes[i];
                        break;
                    }
                    else
                        n*=primes[i];
                }
                else{
                    break;
                }
                n/=primes[i];
                //cout<<n*primes[i]<<"/"<<primes[i]<<" = "<<n<<endl;
                lli mult{primes[i]*2};
                lli q(n);
                while(mult <= q and q%mult==0){
                    if(b==0){
                        b = mult;
                        n=q/mult;
                    }
                    else if(c==0){
                        if(q/mult==1){
                            c=mult;
                            n=q/mult;
                        }
                        else{
                            c=q;
                        }
                    }
                    else{
                        flag = false;
                        break;
                    }
                    q/=mult;
                    mult*=primes[i];
                    //cout<<n*mult<<"/"<<mult<<" = "<<n<<endl;

                }
            }
        }
        //cout<<a<<" "<<b<<" "<<c<<endl;
        if(c!=0){
            cout<<"YES"<<"\n";
            cout<<a<<" "<<b<<" "<<c<<"\n";
        }
        else{
            cout<<"NO"<<"\n";
        }
    }
    return 0;
}


#include <iostream>

using namespace std;

typedef long long int lli;

int main(){
    lli t;
    cin>>t;
    for(int j(0); j<t; j++){
        lli n;
        cin>>n;
        lli a(0), b(0), c(0);
        lli m(n);
        for(int i(2); i<m/2; i++){
            if(c){
                break;
            }
            if(n%i==0){
                if(a==0){
                    a=i;
                }
                else if(b==0){
                    b=i;
                    c = n/b;
                    break;
                }
                n/=i;
            }
        }
        if(c!=0){
            cout<<"YES"<<"\n";
            cout<<a<<" "<<b<<" "<<c<<"\n";
        }
        else{
            cout<<"NO"<<"\n";
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,x=2;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(x*(x+1)*(x+2)>a){
			cout<<"NO"<<endl;
			continue;
		}else{
			cout<<"YES"<<endl;
		}
		while(x*(x+1)*(x+2)==a){
			x++;
		}
		cout<<x<<" "<<x+1<<" "<<x+2<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,n;
	int T;
	cin>>T;
	while(T--)
	{
		cin>>n;
		bool o=0;
		for(int a=2;a<=pow(n,1/3.0);a++)
		{
			for(int b=a+1;b<=pow(n-a,0.5);b++)
			{
				c=n/(a*b);
				if(n%(a*b)==0&&c>=b&&a!=b&&b!=c&&a!=c)
				{
					cout<<"YES"<<endl<<a<<' '<<b<<' '<<c<<endl;
					o=true;
					break;
				}
			}
			if(o)
				break;
		}
		if(!o)cout<<"NO"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int t,n;

bool isprime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}

int main(){
    ios::sync_with_stdio(false);
    cin>>t;
    while(t--){
        cin>>n;
        //if(n<12){cout<<"NO"<<endl;continue;}
        if(isprime(n)){cout<<"NO"<<endl;continue;}
        bool flag=0;
        int a,b,c;
        for(int i=2;i*i<=n;i++){
            if(n%i==0){
                for(int j=2;j*j<=(n/i);j++){
                    if(n%j==0&&i!=j&&i!=(n/i/j)&&j!=(n/i/j)){
                        a=i;
                        b=j;
                        c=n/i/j;
                        flag=1;
                        break;
                    }
                }
            }
            if(flag)break;
        }
        if(flag)cout<<"YES"<<'\n'<<a<<' '<<b<<' '<<c<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#define MAXN 10000005
bool valid[MAXN];
int tot,n,ans[MAXN];
void getPrime()
{
	memset(valid, 1, sizeof(valid));
	valid[0] = valid[1] = false;
	for(int i = 2; i <= n; ++i)
	{
		if(valid[i]) ans[++tot] = i;
		for(int j = 1; j <= tot && i * ans[j] <= n; ++j)
		{
			valid[i * ans[j]] = false;
			if(i % ans[j] == 0) break;
		}
	}
}
using namespace std;
int main(){

	int t;
	cin>>t;
	while(t--){
		cin>>n;
		getPrime();
		if(n<24){
			cout<<"NO"<<endl;
		}
		else{
			int f=0,a=n,b,c,tmp=n;
			for(int i=2;i<n;i++){
				if(tmp%i==0){
					f++;
					tmp=tmp/i;
					a=min(a,i);
				}
				if(valid[tmp]&&f!=2){
					break;
				}
				if(f==2){
					b=i;
					c=tmp;
					break;
				}
			}
			if(f==2){
				if(c!=a&&c!=b&&c!=1){
					cout<<"YES"<<endl;
					cout<<a<<" "<<b<<" "<<c<<endl;
				}
				else
					cout<<"NO"<<endl;
			}
			else{
				cout<<"NO"<<endl;
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long t,n;
bool zs(long long n){
	for(long long i=1;i<=n/2;i++) if(n%i==0) return 1;
	return 0;
}
void a(long long n){
	int f=1;
	for(long long i=2;i<=n/2;i++){
		if(n%i==0){
			for(long long j=2;j<=n/2/i;j++){
				int k=n/i/j;
				if(n%j==0&&k>=2&&i!=j&&i!=k&&j!=k){
					cout<<"YES"<<endl;
					cout<<i<<' '<<j<<' '<<k<<endl;
					f=0;
					break;
				}
			}
			break;
		}
	}
	if(f==1) cout<<"NO"<<endl;
}
int main(){
	cin>>t;
	for(long long i=1;i<=t;i++){
		cin>>n;
		a(n);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a,b,c,t,n;
int s(int n,int m){
	for(int i=2;i*i<=m;i++)
		if(m%i==0) return i;
	return m;
}
int main(){
	cin>>t;
	while(t--){
		cin>>n;
		a=s(2,n);
		b=s(a+1,n/a);
		c=n/(a*b);
		if(a!=b&&b!=c&&a!=c&&a!=1&&b!=1&&c!=1) cout<<"YES"<<endl<<a<<' '<<b<<' '<<c<<endl;
		else cout<<"NO"<<endl;
	}
  	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int t;
int qwe(int x,int i)
{
	for(i++;i<sqrt(x);i++)
		if(x%i==0)
			break;
	if(i>=sqrt(x))
		return -1;
	return i;
}
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		int a=qwe(n,1);
		if(a==-1)
		{
			puts("NO");
			continue;
		}
		n/=a;
		int b=qwe(n,a);
		if(b==-1)
		{
			puts("NO");
			continue;
		}
		int c=n/b;
		if(c==b||c==a)
		{
			puts("NO");
			continue;
		}
		printf("YES\n%d %d %d\n",a,b,c);
	}
	return 0;
}


#include<bits/stdc++.h>
#define re register
using namespace std;
int t,p[100009],c[100009],cnt,num,n;
int main(){
	scanf("%d",&t);
	while(t--){
		cnt=0,num=0;
		memset(p,0,sizeof p);
		memset(c,0,sizeof c);
		scanf("%d",&n);
		int k=sqrt(n),x=n;
		for(re int i=2;i<=k&&(n!=1);++i){
			if(n%i)continue;
			p[++cnt]=i;
			int o1=1,o2=1;
			while(!(n%i)){
				n/=i;++c[cnt];
			}
		}
		if(n>1)p[++cnt]=n,c[cnt]=1;
		if(cnt>=3){printf("YES\n");
			printf("%d %d %d\n",p[1],p[2],x/(p[1]*p[2]));
		}
		else if(cnt==2){
			if(c[1]+c[2]>=4){
				printf("YES\n");
				printf("%d %d %d\n",p[1],p[2],x/(p[1]*p[2]));
			}
			else {
				printf("NO\n");
			}
		}
		else if(cnt<2){
			if(c[1]<6)printf("NO\n");
			else printf("YES\n%d %d %d\n",p[1],p[1]*p[1],x/(p[1]*p[1]));
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
int a,b,c,n;
int main()
{
	int s;
	scanf("%d",&s);
	for(int i=1;i<=s;i++)
	{
		a=b=c=2;
		scanf("%d",&n);
		for(;a<=n/2;a++)
		{
			if(n%a==0)
			{
				n=n/a;
				for(b=a+1;b<=n/2;b++)
				{
					if(n%b==0)
					{
						c=n/b;
						if(c==b)continue;
						printf("YES\n%d %d %d\n",a,b,c);
						goto nxt;
					}
				}
			}
		}
		printf("NO\n");
		nxt:continue;
	}
	return 0;
}


#include<cstdio>
#include<iostream>
using namespace std;
int t,n,flag;
int main()
{
	cin>>t;
	for(int i=1;i<=t;i++)
	{
		flag=0;
		cin>>n;
    	for(int a=2;a<=n;a++)
		for(int b=a+1;(a*b*b)<=n;b++)
		for(int c=b+1;(a*b*c)<=n;c++)
		if((a*b*c)==n)
		{
			cout<<"YES"<<endl;
			cout<<a<<" "<<b<<" "<<c<<endl;
			flag=1;
		}
		if(flag==0) cout<<"NO"<<endl;
	}
}


#include<bits/stdc++.h>
#define re register
using namespace std;
int t,p[100009],c[100009],cnt,num,n;
int main(){
	scanf("%d",&t);
	while(t--){
		cnt=0,num=0;
		memset(p,0,sizeof p);
		memset(c,0,sizeof c);
		scanf("%d",&n);
		int k=sqrt(n),x=n;
		for(re int i=2;i<=k&&(n!=1);++i){
			if(n%i)continue;
			p[++cnt]=i;
			int o1=1,o2=1;
			while(!(n%i)){
				n/=i;++c[cnt];
			}
		}
		if(n>1)p[++cnt]=n,c[cnt]=1;
		if(cnt>=3){printf("YES\n");
			printf("%d %d %d\n",p[1],p[2],x/(p[1]*p[2]));
		}
		else if(cnt==2){
			if(c[1]+c[2]>=4){
				printf("YES\n");
				printf("%d %d %d\n",p[1],p[2],x/(p[1]*p[2]));
			}
			else {
				printf("NO\n");
			}
		}
		else if(cnt<2){
			if(c[1]<6)printf("NO\n");
			else printf("YES\n%d %d %d\n",p[1],p[1]*p[1],x/(p[1]*p[1]*p[1]));
		}
	}
}


#include <cstdio>
#include <cctype>

inline int read (void)
{
	register int x = 0, f = 1, ch = getchar();
	while(!isdigit(ch)) { if(ch == '-') f = -f; ch = getchar(); }
	while(isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}

signed main (void)
{
	int t, n;
	t = read();
	while(t--)
	{
		n = read();
		for(register int a = 2; a * a * a <= n; ++ a)
			if(n % a == 0)
				for(register int b = a + 1; a * b * b <= n; ++ b)
				{
					int N = n / a;
					if(N % b == 0)
					{
						N /= b;
						if(a * b * N == n && N > b)
						{
							printf("YES\n");
							printf("%d %d %d\n", a, b, N);
							goto goto1;
						}
					}
				}
		printf("NO\n");
		goto1:
		;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n,flag=0;
		scanf("%d",&n);
		for(int i=2;i*i<=n;i++)
		{
			if(n%i) continue;
			for(int j=2;j*j<=(n/i);j++)
			{
				if(j==i) continue;
				if(n%(i*j)) continue;
				if(n/(i*j)==i||n/(i*j)==j) continue;
				flag=1;
				printf("YES\n");
				printf("%d %d %d\n",i,j,n/(i*j));
				i=n+1;
				break;
			}
		}
		if(!flag) printf("NO\n");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a,b,c,n;
int main()
{
	int s;
	scanf("%d",&s);
	for(int i=1;i<=s;i++)
	{
		a=b=c=2;
		scanf("%d",&n);
		for(;a<=n/2;a++)
		{
			if(n%a==0)
			{
				n=n/a;
				for(b=a+1;b<=n/2;b++)
				{
					if(n%b==0)
					{
						c=n/b;
						if(c==b)goto fai;
						printf("YES\n%d %d %d\n",a,b,c);
						goto nxt;
					}
				}
			}
		}
		fai:printf("NO\n");
		nxt:continue;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t,n,ans1,ans2,ans3;
int main()
{
	cin>>t;
	for(int i=1;i<=t;++i)
	{
		cin>>n;
		ans1=0,ans2=0,ans3=0;
		for(int j=2;j<=n;++j)
		{
			if(n%j==0 && ans1==0) ans1=j,n/=j;
			else if(n%j==0 && ans2==0) ans2=j,n/=j;
			else if(n%j==0 && ans3==0) ans3=j,n/=j;
		}
		if(ans3!=0) printf("YES\n%d %d %d",ans1,ans2,ans3);
		else printf("NO\n");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define int long long
#define Debug(x) cerr << #x << ": " << x << endl;

inline int read() {
	char c = getchar(); int x = 0, f = 1;
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	return x * f;
}

LL A, B, C; bool flg = false;

inline void divide(int x) {
	for (LL i = (LL)A + 1; i * i <= x; i++)
		if (x % i == 0) {
			B = i; C = x / i;
			if (B != C) {
				flg = true; return;
			}
		}
	flg = false;
}

inline void solve() {
	int N = read(); flg = false;
	for (LL i = 2; i * i <= N; i++)
		if (N % i == 0) {
			A = i; divide(N / i);
			if (flg) {
				puts("YES");
				printf("%I64d %I64d %I64d\n", A, B, C);
				return;
			}
		}
	puts("NO");
}

main() {
	int T = read();
	while (T--) solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int i,j,k,s,n,m,z=1;
int c(int x){
	for(int i=2;i<sqrt(x);i++) if(x%i==0) return 0;
	return 1;
}
int main(){
  	cin>>n;
  	for(i=1;i<=n;i++){
  		cin>>m;
  		if(c(m)==1) cout<<"NO";
  		else{
  		for(j=1;j<=m/2;j++){
 			for(k=1;k<=m/2;k++){
 				for(s=1;s<=m/2;s++)
  					if(s*k*j==m){ z=0;break;}
 				if(z==0) break;
 			}
 			if(z==0) break;
 		}
 		if(z==1) cout<<"YES";
  		else cout<<"NO";
  	}
}
  	return 0;
}


#include<bits/stdc++.h>
#define re register
using namespace std;
int t,p[100009],c[100009],cnt,num,n;
int main(){
	scanf("%d",&t);
	while(t--){
		cnt=0,num=0;
		memset(p,0,sizeof p);
		memset(c,0,sizeof c);
		scanf("%d",&n);
		int k=sqrt(n),x=n;
		for(re int i=2;i<=k&&(n!=1);++i){
			if(n%i)continue;
			p[++cnt]=i;
			int o1=1,o2=1;
			while(!(n%i)){
				n/=i;++c[cnt];
			}
		}
		if(n>1)p[++cnt]=n,c[cnt]=1;
		if(cnt>=3){printf("YES\n");
			printf("%d %d %d\n",p[1],p[2],x/(p[1]*p[2]));
		}
		else if(cnt==2){
			if(c[1]+c[2]>=4){
				printf("YES\n");
				printf("%d %d %d\n",p[1],p[2],x/(p[1]*p[2]));
			}
			else {
				printf("NO\n");
			}
		}
		else if(cnt<2){
			if(c[1]<6)printf("NO\n");
			else printf("YES\n%d %d %d\n",p[1],p[1]*p[1],p[1]*p[1]*p[1]);
		}
	}
}


#include <cstdlib>
#include <stdio.h>
#include <iostream>
#include<cstring>
#include<map>
#include<sstream>
#include<vector>
#include<cmath>
#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=1e5;

int main() {
int t;
scanf("%d",&t);
while(t--)
{int n;
scanf("%d",&n);
bool flag=false;
for(int i=2;i*i<=n;i++)
{if(n%i==0)
{int t=n/i;
for(int j=i+1;j*j<=t;j++)
{if(t%j==0&&t/j!=j)
{printf("YES\n");
printf("%d %d %d\n",i,j,n/i/j);flag=true;break;}}
if(flag) break;
}}
if(!flag) printf("NO\n");
}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,i,x,y,z,u,v=0;
int main(){
 	cin>>n;
 	for(i=1;i<=n;i++){
 		cin>>x>>y>>z>>u;
 		v=x+y+z+u;
 		if(v%3==0&&v%3>=x&&v%3>=y&&v%3>=z) cout<<"YES";
 		else cout<<"NO";
	 }
   	return 0;
}


#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

int p(int x,int y) {
    if(x==1)return 0;
    int sq=sqrt(x);
    for(int i=y;i<=sq;i++) {
        if(x%i==0)
            return i;
    }
    return 0;
}

void solve() {
    int t;
    cin>>t;
    while(t--) {
        long long n;
        cin>>n;
        vector<long long > ans;
        long long num=n;
        int tmp=2;
        int sq=sqrt(num);
        while(true) {
            int di=p(n,tmp);
            if(di) {
                n/=di;
                ans.push_back((di));
                tmp=di+1;
            }
            else {
                cout<<"NO"<<endl;
                break;
            }
            if(ans.size()==2&&n>=tmp) {
                ans.push_back(n);
                cout<<"YES"<<endl;
                cout<<ans[0]<<' '<<ans[1]<<' '<<ans[2]<<endl;
                break;
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);

    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int as(int a, int n){
    for (int i=a;i*i<=n;i++){
        if(n%i==0)return i;
    }
    return n;
}
int main(){
    int n,x,a,b,c;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a=as(2,x);
        b=as(a+1,x/a);
        c=x/(a*b);
        if (a!=b&&b!=c&&a!=c&&a!=1&&b!=1&&c!=1){
            cout<<"YES"<<endl<<a<<' '<<b<<' '<<c<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,m;
int main()
{
    scanf("%d",&n);
    for(int i = 1 ; i <= n ; ++ i){
        scanf("%d",&m);
        int bbb = 1;
        for(int j = 2 ; j <= sqrt(m) ; ++ j){
            if(m % j == 0){int qwe = m/j;
                for(int d = j+1 ; d <= sqrt(qwe) ; ++ d){
                    if(qwe % d == 0 && qwe / d > d){

                            printf("YES\n%d %d %d",j,d,qwe/d);
                            bbb = 0;
                            break;
                    }
                }

        }
    }
        if(bbb == 1)
            printf("NO\n");
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t,n,a,b,c,flag=0;
	cin>>t;
	for(int i=0;i<t;i++)
	{
		cin>>n;
		for(a=2;a<n/6;a++)
		{
			for(b=2;b<n/a;b++)
			{
				c=n/a/b;
				if(c>1)
				{
					if(a*b*c==n&&a!=b&&b!=c&&c!=a)
					{
						flag=1;
						break;
					}
				}

			}
			if(flag==1)
			{
				break;
			}
		}
		if(flag==1)
		{
			cout<<"YES\n"<<a<<" "<<b<<" "<<c<<endl;
		}
		else
		{
			cout<<"NO\n";
		}
		flag=0;
	}
	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main() {

	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
	int t;
	cin >> t;
	while (t-- > 0) {

		int n;
		cin >> n;
		vector<pair<int, int> > primes;

		for (int i = 2; i * i <= n; i++) {
			int cnt = 0;
			if (n % i == 0) {
				while (n % i == 0) {
					n = n / i;
					cnt++;
				}
				primes.push_back(make_pair(i, cnt));
			}

		}

		if (n != 1) {
			primes.push_back(make_pair(n, 1));
		}

		if (primes.size() >= 3) {
			cout << "YES" << endl;
			cout << primes[0].first << " " << primes[1].first << " " << primes[2].first << endl;
			continue;
		}
		else if (primes[0].second >= 6) {
			int p = primes[0].first;
			cout << "YES" << endl;
			cout << p << " " << (long long)p*p << " " << (long long)p*p*p << endl;
			continue;
		}
		else {
			if (primes.size() == 2) {
				if (primes[0].second >= 3) {
					int p1 = primes[0].first;
					int p2 = primes[1].first;
					cout << "YES" << endl;
					cout << p1 << " " << p1*p1 * 1LL << " " << p2 << endl;
				}
				else if ( primes[1].second >= 3) {
					int p1 = primes[0].first;
					int p2 = primes[1].first;
					cout << "YES" << endl;
					cout << p1 << " " << p2 << " " << (long long)p2*p2 << endl;
				}
				else {
					cout << "NO" << endl;
				}
				continue;
			}
		}
		cout<<"NO"<<endl;

	}

	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int t;
	cin >> t;
	while (t-- > 0) {

		int n;
		cin >> n;
		int n2 = n;
		vector<pair<int, int> > primes;

		for (int i = 2; i * i <= n; i++) {
			int cnt = 0;
			if (n % i == 0) {
				while (n % i == 0) {
					n = n / i;
					cnt++;
				}
				primes.push_back(make_pair(i, cnt));
			}

		}

		if (n != 1) {
			primes.push_back(make_pair(n, 1));
		}

		if (primes.size() >= 3) {
			cout << "YES" << endl;
			cout << primes[0].first << " " << primes[1].first << " " << n2/((primes[0].first)*(primes[1].first)*1LL) << endl;
			continue;
		}
		else if (primes[0].second >= 6) {
			int p = primes[0].first;
			cout << "YES" << endl;
			cout << p << " " << (long long)p*p << " " << (n2/(long long)p*p*p) << endl;
			continue;
		}
		else {
			if (primes.size() == 2) {
				int p1 = primes[0].first;
				int p2 = primes[1].first;

				int x = n2 / (p1);
				x = x / p2;

				int a = min(p1, p2);
				a = min(a, x);

				int c = max(p1, p2);
				c = max(c, x);

				int b = n2 / a;
				b = b / c;

				if (x != p1 && x != p2 && x >= 2)
				{
					cout << "YES" << endl;
					cout << a << " " << b << " " << c << endl;
				}
				else {
					cout << "NO" << endl;
				}

			}
			else {
				cout << "NO" << endl;

			}
			continue;
		}
		cout << "NO" << endl;

	}

	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int t;
	cin >> t;
	while (t-- > 0) {

		int n;
		cin >> n;
		int n2 = n;
		vector<pair<int, int> > primes;

		for (int i = 2; i * i <= n; i++) {
			int cnt = 0;
			if (n % i == 0) {
				while (n % i == 0) {
					n = n / i;
					cnt++;
				}
				primes.push_back(make_pair(i, cnt));
			}

		}

		if (n != 1) {
			primes.push_back(make_pair(n, 1));
		}

		if (primes.size() >= 3) {
			cout << "YES" << endl;
			cout << primes[0].first << " " << primes[1].first << " " << primes[2].first << endl;
			continue;
		}
		else if (primes[0].second >= 6) {
			int p = primes[0].first;
			cout << "YES" << endl;
			cout << p << " " << (long long)p*p << " " << (long long)p*p*p << endl;
			continue;
		}
		else {
			if (primes.size() == 2) {
				int p1 = primes[0].first;
				int p2 = primes[1].first;
				int x = n2 / (1LL * p1 * p2);

				if (x != p1 && x != p2 && x>=2)
				{
					cout << "YES"<<endl;
					cout << p1 << " " << p2 << " " << x << endl;
				}
				else {
					cout << "NO";
				}

			}
			else {
				cout << "NO" << endl;

			}
			continue;
		}
		cout << "NO" << endl;

	}

	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int t;
	cin >> t;
	while (t-- > 0) {

		int n;
		cin >> n;
		int n2 = n;
		vector<pair<int, int> > primes;

		for (int i = 2; i * i <= n; i++) {
			int cnt = 0;
			if (n % i == 0) {
				while (n % i == 0) {
					n = n / i;
					cnt++;
				}
				primes.push_back(make_pair(i, cnt));
			}

		}

		if (n != 1) {
			primes.push_back(make_pair(n, 1));
		}

		if (primes.size() >= 3) {
			cout << "YES" << endl;
			cout << primes[0].first << " " << primes[1].first << " " << primes[2].first << endl;
			continue;
		}
		else if (primes[0].second >= 6) {
			int p = primes[0].first;
			cout << "YES" << endl;
			cout << p << " " << (long long)p*p << " " << (long long)p*p*p << endl;
			continue;
		}
		else {
			if (primes.size() == 2) {
				int p1 = primes[0].first;
				int p2 = primes[1].first;
				int x = n2 / (1LL * p1 * p2);

				if (x != p1 && x != p2 && x>=2)
				{
					cout << "YES"<<endl;
					cout << p1 << " " << p2 << " " << x << endl;
				}
				else {
					cout << "NO"<<endl;
				}

			}
			else {
				cout << "NO" << endl;

			}
			continue;
		}
		cout << "NO" << endl;

	}

	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int t;
	cin >> t;
	while (t-- > 0) {

		int n;
		cin >> n;
		int n2 = n;
		vector<pair<int, int> > primes;

		for (int i = 2; i * i <= n; i++) {
			int cnt = 0;
			if (n % i == 0) {
				while (n % i == 0) {
					n = n / i;
					cnt++;
				}
				primes.push_back(make_pair(i, cnt));
			}

		}

		if (n != 1) {
			primes.push_back(make_pair(n, 1));
		}

		if (primes.size() >= 3) {
			cout << "YES" << endl;
			cout << primes[0].first << " " << primes[1].first << " " << n2/((primes[0].first)*(primes[1].first)*1LL) << endl;
			continue;
		}
		else if (primes[0].second >= 6) {
			int p = primes[0].first;
			cout << "YES" << endl;
			cout << p << " " << (long long)p*p << " " << (n2/((long long)p*p*p)) << endl;
			continue;
		}
		else {
			if (primes.size() == 2) {
				int p1 = primes[0].first;
				int p2 = primes[1].first;

				int x = n2 / (p1);
				x = x / p2;

				int a = min(p1, p2);
				a = min(a, x);

				int c = max(p1, p2);
				c = max(c, x);

				int b = n2 / a;
				b = b / c;

				if (x != p1 && x != p2 && x >= 2)
				{
					cout << "YES" << endl;
					cout << a << " " << b << " " << c << endl;
				}
				else {
					cout << "NO" << endl;
				}

			}
			else {
				cout << "NO" << endl;

			}
			continue;
		}
		cout << "NO" << endl;

	}

	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int t;
	cin >> t;
	while (t-- > 0) {

		int n;
		cin >> n;
		int n2 = n;
		vector<pair<int, int> > primes;

		for (int i = 2; i * i <= n; i++) {
			int cnt = 0;
			if (n % i == 0) {
				while (n % i == 0) {
					n = n / i;
					cnt++;
				}
				primes.push_back(make_pair(i, cnt));
			}

		}

		if (n != 1) {
			primes.push_back(make_pair(n, 1));
		}

		if (primes.size() >= 3) {
			cout << "YES" << endl;
			cout << primes[0].first << " " << primes[1].first << " " << primes[2].first << endl;
			continue;
		}
		else if (primes[0].second >= 6) {
			int p = primes[0].first;
			cout << "YES" << endl;
			cout << p << " " << (long long)p*p << " " << (long long)p*p*p << endl;
			continue;
		}
		else {
			if (primes.size() == 2) {
				int p1 = primes[0].first;
				int p2 = primes[1].first;
				int x = n2 / (p1);
				x = x / p2;
				int a = min(p1, p2);
				a = min(p1, x);
				int c = max(p1, p2);
				c = max(p1, x);
				int b = n2 / a;
				b = b / c;

				if (x != p1 && x != p2 && x >= 2)
				{
					cout << "YES" << endl;
					cout << a << " " << b << " " << c << endl;
				}
				else {
					cout << "NO" << endl;
				}

			}
			else {
				cout << "NO" << endl;

			}
			continue;
		}
		cout << "NO" << endl;

	}

	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int t;
	cin >> t;
	while (t-- > 0) {

		int n;
		cin >> n;
		int n2 = n;
		vector<pair<int, int> > primes;

		for (int i = 2; i * i <= n; i++) {
			int cnt = 0;
			if (n % i == 0) {
				while (n % i == 0) {
					n = n / i;
					cnt++;
				}
				primes.push_back(make_pair(i, cnt));
			}

		}

		if (n != 1) {
			primes.push_back(make_pair(n, 1));
		}

		if (primes.size() >= 3) {
			cout << "YES" << endl;
			cout << primes[0].first << " " << primes[1].first << " " << primes[2].first << endl;
			continue;
		}
		else if (primes[0].second >= 6) {
			int p = primes[0].first;
			cout << "YES" << endl;
			cout << p << " " << (long long)p*p << " " << (long long)p*p*p << endl;
			continue;
		}
		else {
			if (primes.size() == 2) {
				int p1 = primes[0].first;
				int p2 = primes[1].first;
				int x = n2 / (1LL * p1 * p2);

				if (x != p1 && x != p2 && x>=2)
				{
					cout << "YES"<<endl;
					cout << p1 << " " << p2 << " " << x << endl;
				}
				else {
					cout << "NO";
				}
				continue;

			}
			else {
				cout << "NO" << endl;
			}
			continue;
		}
		cout << "NO" << endl;

	}

	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int t;
	cin >> t;
	while (t-- > 0) {

		int n;
		cin >> n;
		int n2 = n;
		vector<pair<int, int> > primes;

		for (int i = 2; i * i <= n; i++) {
			int cnt = 0;
			if (n % i == 0) {
				while (n % i == 0) {
					n = n / i;
					cnt++;
				}
				primes.push_back(make_pair(i, cnt));
			}

		}

		if (n != 1) {
			primes.push_back(make_pair(n, 1));
		}

		if (primes.size() >= 3) {
			cout << "YES" << endl;
			cout << primes[0].first << " " << primes[1].first << " " << primes[2].first << endl;
			continue;
		}
		else if (primes[0].second >= 6) {
			int p = primes[0].first;
			cout << "YES" << endl;
			cout << p << " " << (long long)p*p << " " << (long long)p*p*p << endl;
			continue;
		}
		else {
			if (primes.size() == 2) {
				int p1 = primes[0].first;
				int p2 = primes[1].first;
				int x = n2 / (1LL * p1 * p2);

				if (x != p1 && x != p2)
				{
					cout << "YES"<<endl;
					cout << p1 << " " << p2 << " " << x << endl;
				}
				else {
					cout << "NO";
				}
				continue;

			}
			else {
				cout << "NO" << endl;
			}
			continue;
		}
		cout << "NO" << endl;

	}

	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int t;
	cin >> t;
	while (t-- > 0) {

		int n;
		cin >> n;
		int n2 = n;
		vector<pair<int, int> > primes;

		for (int i = 2; i * i <= n; i++) {
			int cnt = 0;
			if (n % i == 0) {
				while (n % i == 0) {
					n = n / i;
					cnt++;
				}
				primes.push_back(make_pair(i, cnt));
			}

		}

		if (n != 1) {
			primes.push_back(make_pair(n, 1));
		}

		if (primes.size() >= 3) {
			cout << "YES" << endl;
			cout << primes[0].first << " " << primes[1].first << " " << primes[2].first << endl;
			continue;
		}
		else if (primes[0].second >= 6) {
			int p = primes[0].first;
			cout << "YES" << endl;
			cout << p << " " << (long long)p*p << " " << (long long)p*p*p << endl;
			continue;
		}
		else {
			if (primes.size() == 2) {
				int p1 = primes[0].first;
				int p2 = primes[1].first;
				int x = n2 / (p1);
				x = x / p2;
				int a = min(p1, p2);
				a = min(p1, x);
				c = max(p1, p2);
				c = max(p1, x);
				b = n2 / a;
				b = b / c;

				if (x != p1 && x != p2 && x >= 2)
				{
					cout << "YES" << endl;
					cout << a << " " << b << " " << c << endl;
				}
				else {
					cout << "NO" << endl;
				}

			}
			else {
				cout << "NO" << endl;

			}
			continue;
		}
		cout << "NO" << endl;

	}

	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int t;
	cin >> t;
	while (t-- > 0) {

		int n;
		cin >> n;
		int n2 = n;
		vector<pair<int, int> > primes;

		for (int i = 2; i * i <= n; i++) {
			int cnt = 0;
			if (n % i == 0) {
				while (n % i == 0) {
					n = n / i;
					cnt++;
				}
				primes.push_back(make_pair(i, cnt));
			}

		}

		if (n != 1) {
			primes.push_back(make_pair(n, 1));
		}

		if (primes.size() >= 3) {
			cout << "YES" << endl;
			cout << primes[0].first << " " << primes[1].first << " " << primes[2].first << endl;
			continue;
		}
		else if (primes[0].second >= 6) {
			int p = primes[0].first;
			cout << "YES" << endl;
			cout << p << " " << (long long)p*p << " " << (long long)p*p*p << endl;
			continue;
		}
		else {
			if (primes.size() == 2) {
				int p1 = primes[0].first;
				int p2 = primes[1].first;

				int x = n2 / (p1);
				x = x / p2;

				int a = min(p1, p2);
				a = min(a, x);

				int c = max(p1, p2);
				c = max(c, x);

				int b = n2 / a;
				b = b / c;

				if (x != p1 && x != p2 && x >= 2)
				{
					cout << "YES" << endl;
					cout << a << " " << b << " " << c << endl;
				}
				else {
					cout << "NO" << endl;
				}

			}
			else {
				cout << "NO" << endl;

			}
			continue;
		}
		cout << "NO" << endl;

	}

	return 0;
}


#include<bits/stdc++.h>
using  namespace  std;

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

ll prime(ll x)
{
    if(x < 2)
        return 0;
    if(x == 2)
        return 1;
    if(x%2 == 0)
        return 0;
    ll root = sqrt(x);
    for(ll i=3; i<=root; i+=2)
    {
        if(x%i == 0)
            return 0;
    }
    return 1;
}

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        llu n,ans,a=0,b=1,c;
        cin>>n;
        if(prime(n))
            cout<<"NO"<<nl;
        else
        {
            for(int i=1; i<=n; i++)
            {
                if(n%i==0 && i!=1)
                {
                    a=i;
                    break;
                }
            }
            ans=n/a;
            for(int i=1; i<=ans; i++)
            {
                if(ans%i==0 && i!=1 && i!=a)
                {
                    b=i;
                    break;
                }
            }

            c=n/(a*b);
            if(c==1 || c==a || c==b)
                cout<<"NO"<<nl;
            else
            {
                cout<<"YES"<<nl;
                cout<<a<<' '<<b<<' '<<c<<nl;
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using  namespace  std;

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,ans;
        cin>>n;
        vector<ll>v;
        for(int i=2; i<(n/2); i++)
        {
            if(n%i==0)
            {
                v.push_back(i);
            }
        }

        if(v.size()<3)
            cout<<"NO"<<nl;
        else
        {
            for(int i=0; i<v.size(); i++)
            {
                ans=v[i]*v[i+1]*v[i+2];
                if(ans==n)
                {
                    cout<<"YES"<<nl;
                    cout<<v[i]<<' '<<v[i+1]<<' '<<v[i+2]<<nl;
                    break;
                }
                else
                {
                    cout<<"NO"<<nl;
                    break;
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using  namespace  std;

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

ll prime(ll x)
{
    if(x < 2)
        return 0;
    if(x == 2)
        return 1;
    if(x%2 == 0)
        return 0;
    ll root = sqrt(x);
    for(ll i=3; i<=root; i+=2)
    {
        if(x%i == 0)
            return 0;
    }
    return 1;
}

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        llu n,ans,a=0,b=0,c;
        cin>>n;
        if(prime(n))
            cout<<"NO"<<nl;
        else
        {
            for(int i=1; i<=n; i++)
            {
                if(n%i==0 && i!=1)
                {
                    a=i;
                    break;
                }
            }
            ans=n/a;
            for(int i=1; i<=ans; i++)
            {
                if(ans%i==0 && i!=1 && i!=a)
                {
                    b=i;
                    break;
                }
            }

            c=n/(a*b);
            if(c==1 || c==a || c==b)
                cout<<"NO"<<nl;
            else
            {
                cout<<"YES"<<nl;
                cout<<a<<' '<<b<<' '<<c<<nl;
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using  namespace  std;

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

ll prime(ll x)
{
    if(x < 2)
        return 0;
    if(x == 2)
        return 1;
    if(x%2 == 0)
        return 0;
    ll root = sqrt(x);
    for(ll i=3; i<=root; i+=2)
    {
        if(x%i == 0)
            return 0;
    }
    return 1;
}

int main()
{
    faster
    int t;
    cin>>t;
    while(t--)
    {
        llu n,ans,a=0,b=1,c;
        cin>>n;
        if(prime(n))
            cout<<"NO"<<nl;
        else
        {
            for(int i=1; i<=n; i++)
            {
                if(n%i==0 && i!=1)
                {
                    a=i;
                    break;
                }
            }
            ans=n/a;
            for(int i=1; i<=ans; i++)
            {
                if(ans%i==0 && i!=1 && i!=a)
                {
                    b=i;
                    break;
                }
            }

            c=n/(a*b);
            if(c==1 || c==a || c==b)
                cout<<"NO"<<nl;
            else
            {
                cout<<"YES"<<nl;
                cout<<a<<' '<<b<<' '<<c<<nl;
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using  namespace  std;

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    faster
    int t;
    cin>>t;
    while(t--)
    {
        llu n,ans,a=0,b=0,c=0;
        cin>>n;
        for(int i=1; i<=sqrt(n); i++)
        {
            if(n%i==0 && i!=1)
            {
                a=i;
                break;
            }
        }
        if(a==0)
            cout<<"NO"<<nl;
        else
        {
            ans=n/a;
            for(int i=2; i<=sqrt(ans); i++)
            {
                if(ans%i==0 && i!=a)
                {
                    b=i;
                    break;
                }
            }
            if(b==0)
                cout<<"NO"<<nl;
            else
            {
                c=n/(a*b);
                if(c==1 || c==a || c==b)
                    cout<<"NO"<<nl;
                else
                {
                    cout<<"YES"<<nl;
                    cout<<a<<' '<<b<<' '<<c<<nl;
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using  namespace  std;

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

ll prime(ll x)
{
    if(x < 2)
        return 0;
    if(x == 2)
        return 1;
    if(x%2 == 0)
        return 0;
    ll root = sqrt(x);
    for(ll i=3; i<=root; i+=2)
    {
        if(x%i == 0)
            return 0;
    }
    return 1;
}

int main()
{
    faster
    int t;
    cin>>t;
    while(t--)
    {
        llu n,ans,a=1,b=1,c;
        cin>>n;
        if(prime(n) || prime(n/2))
            cout<<"NO"<<nl;
        else
        {
            for(int i=1; i<=n/2; i++)
            {
                if(n%i==0 && i!=1)
                {
                    a=i;
                    break;
                }
            }
            ans=n/a;
            for(int i=1; i<=ans; i++)
            {
                if(ans%i==0 && i!=1 && i!=a)
                {
                    b=i;
                    break;
                }
            }

            c=n/(a*b);
            if(c==1 || c==a || c==b)
                cout<<"NO"<<nl;
            else
            {
                cout<<"YES"<<nl;
                cout<<a<<' '<<b<<' '<<c<<nl;
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using  namespace  std;

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

ll prime(ll x)
{
    if(x < 2)
        return 0;
    if(x == 2)
        return 1;
    if(x%2 == 0)
        return 0;
    ll root = sqrt(x);
    for(ll i=3; i<=root; i+=2)
    {
        if(x%i == 0)
            return 0;
    }
    return 1;
}

int main()
{
    faster
    int t;
    cin>>t;
    while(t--)
    {
        llu n,ans,a=0,b=1,c;
        cin>>n;
        if(prime(n) || prime(n/2))
            cout<<"NO"<<nl;
        else
        {
            for(int i=1; i<=n; i++)
            {
                if(n%i==0 && i!=1)
                {
                    a=i;
                    break;
                }
            }
            ans=n/a;
            for(int i=1; i<=ans; i++)
            {
                if(ans%i==0 && i!=1 && i!=a)
                {
                    b=i;
                    break;
                }
            }

            c=n/(a*b);
            if(c==1 || c==a || c==b)
                cout<<"NO"<<nl;
            else
            {
                cout<<"YES"<<nl;
                cout<<a<<' '<<b<<' '<<c<<nl;
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using  namespace  std;

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

ll prime(ll x)
{
    if(x < 2)
        return 0;
    if(x == 2)
        return 1;
    if(x%2 == 0)
        return 0;
    ll root = sqrt(x);
    for(ll i=3; i<=root; i+=2)
    {
        if(x%i == 0)
            return 0;
    }
    return 1;
}

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        llu n,ans,a=0,b=0,c;
        cin>>n;
        if(prime(n))
            cout<<"NO"<<nl;
        else
        {
            for(int i=2; i<(n/2); i++)
            {
                if(n%i==0)
                {
                    a=i;
                    break;
                }
            }
            ans=n/a;
            for(int i=1; i<=ans; i++)
            {
                if(ans%i==0 && i!=1 && i!=a)
                {
                    b=i;
                    break;
                }
            }

            c=n/(a*b);
            if(c==1 || c==a || c==b)
                cout<<"NO"<<nl;
            else
            {
                cout<<"YES"<<nl;
                cout<<a<<' '<<b<<' '<<c<<nl;
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using  namespace  std;

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

ll prime(ll x)
{
    if(x < 2)
        return 0;
    if(x == 2)
        return 1;
    if(x%2 == 0)
        return 0;
    ll root = sqrt(x);
    for(ll i=3; i<=root; i+=2)
    {
        if(x%i == 0)
            return 0;
    }
    return 1;
}

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,ans,a=0,b=0,c;
        cin>>n;
        if(prime(n))
            cout<<"NO"<<nl;
        else
        {
            for(int i=2; i<(n/2); i++)
            {
                if(n%i==0)
                {
                    a=i;
                    break;
                }
            }

            for(int i=1; i<=(n/a); i++)
            {
                if((n/a)%i==0 && i!=1 && i!=a)
                {
                    b=i;
                    break;
                }
            }

            c=n/(a*b);
            if(c==1 || c==a || c==b)
                cout<<"NO"<<nl;
            else
            {
                cout<<"YES"<<nl;
                cout<<a<<' '<<b<<' '<<c<<nl;
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int N=105;
#define int long long
struct node{
	int v,n;
};
signed main()
{
	int t;cin>>t;
	while(t--)
	{
		int n;cin>>n;
		vector<node> v;
		int N=n;
		int s=0;
		int x=0;
		for(int i=2;i<=n;i++)
		{
//			if(i>sqrt(N)&&s==0)break;
//			if(i>2*sqrt(N/2)&&s<2)break;
			if(n%i==0)
			{
				int cnt=0;
				while(n%i==0)
				{
					n/=i;cnt++;
				}
				if(cnt<3){s+=1;v.push_back(node{i,1});}
				else if(cnt<6){s+=2;v.push_back(node{i,2});}
				else {s+=3;v.push_back(node{i,3});}
				if(cnt==2||cnt==4||cnt==5)x++;
				if(x>=2)s++;
				if(s>=3)break;
				else if(s==2&&n>1){s++;break;}
			}
		}
		if(s<3)puts("NO");
		else
		{
			int cnt=2;
			puts("YES");
			for(int i=0;i<v.size()&&cnt;i++)
			{
				if(v[i].n==1)
				{
					cout<<v[i].v<<' ';
					cnt--;
					N/=v[i].v;
				}
				else if(v[i].n>1&&cnt==2)
				{
					cout<<v[i].v<<' '<<v[i].v*v[i].v<<' ';
					cnt-=2;
					N/=v[i].v*v[i].v*v[i].v;
				}
				else if(v[i].n>1&&cnt==1)
				{
					cout<<v[i].v<<' ';
					cnt--;
					N/=v[i].v;
				}
			}
			cout<<N<<'\n';
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int N=105;
struct node{
	int v,n;
};

signed main()
{
	int t;cin>>t;
	while(t--)
	{
		int n;cin>>n;
		vector<node> v;
		int N=n;
		int s=0;
		for(int i=2;i<=n;i++)
		{
			if(i>=sqrt(N)&&v.size()==0)break;
			if(n%i==0)
			{

				int cnt=0;
				while(n%i==0)
				{
					n/=i;cnt++;
				}
				v.push_back(node{i,cnt});
				if(cnt<3)s+=1;
				else if(cnt<6)s+=2;
				else s+=3;
			}
		}
		int cnt=2;
		if(s<3)puts("NO");
		else
		{
			puts("YES");
			for(int i=0;i<v.size()&&cnt;i++)
			{
				if(v[i].n<3&&cnt)
				{
					cout<<v[i].v<<' ';
					cnt--;N/=v[i].v;
				}
				else if(cnt==2)
				{
					cout<<v[i].v<<' '<<v[i].v*v[i].v<<' ';
					cnt-=2;
					N/=v[i].v*v[i].v*v[i].v;
				}
				else if(cnt==1)
				{
					cout<<v[i].v<<' ';
					cnt--;N/=v[i].v;
				}
			}
			cout<<N<<'\n';
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int N=105;
struct node{
	int v,n;
};
signed main()
{
	int t;cin>>t;
	while(t--)
	{
		int n;cin>>n;
		vector<node> v;
		int N=n;
		int s=0;
		for(int i=2;i<=N;i++)
		{
			if(i>sqrt(N)&&v.size()==0)break;
			//if(i>2*sqrt(N/2)&&s<=1)break;
			if(n%i==0)
			{
				int cnt=0;
				while(n%i==0)
				{
					n/=i;cnt++;
				}
				v.push_back(node{i,cnt});
				if(cnt<3)s+=1;
				else if(cnt<6)s+=2;
				else s+=3;
				if(s>=3)break;
				if(s==2&&n>1)
				{
					s++;break;
				}
			}
		}
		if(s<3)puts("NO");
		else
		{
			int cnt=2;
			puts("YES");
			for(int i=0;i<v.size()&&cnt;i++)
			{
				if(v[i].n<3&&cnt)
				{
					cout<<v[i].v<<' ';
					cnt--;
					N/=v[i].v;
				}
				else if(cnt==2)
				{
					cout<<v[i].v<<' '<<v[i].v*v[i].v<<' ';
					cnt-=2;
					N/=v[i].v*v[i].v*v[i].v;
				}
				else if(cnt==1)
				{
					cout<<v[i].v<<' ';
					cnt--;
					N/=v[i].v;
				}
			}
			cout<<N<<'\n';
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int N=105;
struct node{
	int v,n;
};
signed main()
{
	int t;cin>>t;
	while(t--)
	{
		int n;cin>>n;
		vector<node> v;
		int N=n;
		int s=0;
		for(int i=2;i<=n;i++)
		{
			if(i>sqrt(N)&&v.size()==0)break;
			if(n%i==0)
			{
				int cnt=0;
				while(n%i==0)
				{
					n/=i;cnt++;
				}
				v.push_back(node{i,cnt});
				if(cnt<3)s+=1;
				else if(cnt<6)s+=2;
				else s+=3;
				if(s>=3)break;
			}
		}
		if(s<3)puts("NO");
		else
		{
			int cnt=2;
			puts("YES");
			for(int i=0;i<v.size()&&cnt;i++)
			{
				if(v[i].n<3&&cnt)
				{
					cout<<v[i].v<<' ';
					cnt--;
					N/=v[i].v;
				}
				else if(cnt==2)
				{
					cout<<v[i].v<<' '<<v[i].v*v[i].v<<' ';
					cnt-=2;
					N/=v[i].v*v[i].v*v[i].v;
				}
				else if(cnt==1)
				{
					cout<<v[i].v<<' ';
					cnt--;
					N/=v[i].v;
				}
			}
			cout<<N<<'\n';
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int N=105;
struct node{
	int v,n;
};
signed main()
{
	int t;cin>>t;
	while(t--)
	{
		int n;cin>>n;
		vector<node> v;
		int N=n;
		int s=0;
		for(int i=2;i<=N;i++)
		{
			if(i>sqrt(N)&&v.size()==0)break;
			if(i>2*sqrt(N/2)&&s<=1)break;
			if(n%i==0)
			{
				int cnt=0;
				while(n%i==0)
				{
					n/=i;cnt++;
				}
				v.push_back(node{i,cnt});
				if(cnt<3)s+=1;
				else if(cnt<6)s+=2;
				else s+=3;
				if(s>=3)break;
				if(s==2&&n>1)
				{
					s++;break;
				}
			}
		}
		if(s<3)puts("NO");
		else
		{
			int cnt=2;
			puts("YES");
			for(int i=0;i<v.size()&&cnt;i++)
			{
				if(v[i].n<3&&cnt)
				{
					cout<<v[i].v<<' ';
					cnt--;
					N/=v[i].v;
				}
				else if(cnt==2)
				{
					cout<<v[i].v<<' '<<v[i].v*v[i].v<<' ';
					cnt-=2;
					N/=v[i].v*v[i].v*v[i].v;
				}
				else if(cnt==1)
				{
					cout<<v[i].v<<' ';
					cnt--;
					N/=v[i].v;
				}
			}
			cout<<N<<'\n';
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int N=105;
#define int long long
struct node{
	int v,n;
};
signed main()
{
	int t;cin>>t;
	while(t--)
	{
		int n;cin>>n;
		vector<node> v;
		int N=n;
		int s=0;
		int x=0;
		for(int i=2;i<=sqrt(N);i++)
		{
			if(i>sqrt(N)&&s==0)break;
			if(n%i==0)
			{
				int cnt=0;
				while(n%i==0)
				{
					n/=i;cnt++;
				}
				if(cnt<3){s+=1;v.push_back(node{i,1});}
				else if(cnt<6){s+=2;v.push_back(node{i,2});}
				else {s+=3;v.push_back(node{i,3});}
				if(cnt==2||s>3)x++;
				if(x>=2)s++;
				if(s>=3)break;
				else if(s==2&&n>1){s++;break;}
			}
		}
		if(s<3)puts("NO");
		else
		{
			int cnt=2;
			puts("YES");
			for(int i=0;i<v.size()&&cnt;i++)
			{
				if(v[i].n==1)
				{
					cout<<v[i].v<<' ';
					cnt--;
					N/=v[i].v;
				}
				else if(v[i].n>1&&cnt==2)
				{
					cout<<v[i].v<<' '<<v[i].v*v[i].v<<' ';
					cnt-=2;
					N/=v[i].v*v[i].v*v[i].v;
				}
				else if(v[i].n>1&&cnt==1)
				{
					cout<<v[i].v<<' ';
					cnt--;
					N/=v[i].v;
				}
			}
			cout<<N<<'\n';
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int N=105;
#define int long long
struct node{
	int v,n;
};
signed main()
{
	int t;cin>>t;
	while(t--)
	{
		int n;cin>>n;
		vector<node> v;
		int N=n;
		int s=0;
		int x=0;
		for(int i=2;i<=sqrt(N);i++)
		{
			if(i>sqrt(N)&&s==0)break;
			if(i>2*sqrt(N/2)&&s<2)break;
			if(n%i==0)
			{
				int cnt=0;
				while(n%i==0)
				{
					n/=i;cnt++;
				}
				if(cnt<3){s+=1;v.push_back(node{i,1});}
				else if(cnt<6){s+=2;v.push_back(node{i,2});}
				else {s+=3;v.push_back(node{i,3});}
				if(cnt==2||cnt==4||cnt==5)x++;
				if(x>=2)s++;
				if(s>=3)break;
				else if(s==2&&n>1){s++;break;}
			}
		}
		if(s<3)puts("NO");
		else
		{
			int cnt=2;
			puts("YES");
			for(int i=0;i<v.size()&&cnt;i++)
			{
				if(v[i].n==1)
				{
					cout<<v[i].v<<' ';
					cnt--;
					N/=v[i].v;
				}
				else if(v[i].n>1&&cnt==2)
				{
					cout<<v[i].v<<' '<<v[i].v*v[i].v<<' ';
					cnt-=2;
					N/=v[i].v*v[i].v*v[i].v;
				}
				else if(v[i].n>1&&cnt==1)
				{
					cout<<v[i].v<<' ';
					cnt--;
					N/=v[i].v;
				}
			}
			cout<<N<<'\n';
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int N=105;
#define int long long
struct node{
	int v,n;
};

signed main()
{
	int t;cin>>t;
	while(t--)
	{
		int n;cin>>n;
		vector<node> v;
		int N=n;
		int s=0;
		for(int i=2;i<=n;i++)
		{
			if(i>=sqrt(N)&&v.size()==0)break;
			if(n%i==0)
			{

				int cnt=0;
				while(n%i==0)
				{
					n/=i;cnt++;
				}
				v.push_back(node{i,cnt});
				if(cnt<3)s+=1;
				else if(cnt<6)s+=2;
				else s+=3;
			}
		}
		int cnt=2;
		if(s<3)puts("NO");
		else
		{
			puts("YES");
			for(int i=0;i<v.size()&&cnt;i++)
			{
				if(v[i].n<3&&cnt)
				{
					printf("%d ",v[i].v);cnt--;N/=v[i].v;
				}
				else if(cnt==2)
				{
					printf("%d %d ",v[i].v,v[i].v*v[i].v);cnt-=2;
					N/=v[i].v*v[i].v*v[i].v;
				}
				else if(cnt==1)
				{
					printf("%d ",v[i].v);cnt--;N/=v[i].v;
				}
			}
			cout<<N<<'\n';
		}
	}
}


#include<bits/stdc++.h>
#include<fstream>
#define s(x) scanf("%d",&(x))
#define print(x) printf("%d ",x)
#define printnl(x) printf("%d\n",x);
#define fi(i,a,b) for(int i=(a);i<(b);i++)
#define fd(i,a,b) for(int i=(a);i=>(b);--i)
#define MOD 1000000009
#define infy 1e18
#define llu  long long unsigned
#define ll long long
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
/*By using these macros we can traverse every kind of container, not only vector. This will produce const_iterator for const object and normal iterator for non-const object, and you will never get an error here.
 void f(const vector<int>& v) {
      int r = 0;
      tr(v, it) {
           r += (*it)*(*it);
      }
      return r;
 }*/
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end() 	// sort(X.rbegin(), X.rend()); // Sort array in descending order using with reverse iterators
#define pb push_back		//Push_back adds an element to the end of vector, increasing its size by one
#define isEmpty(v) = v.empty();	//using v.size() takes O(n)
using namespace::std;

typedef vector <int> vi;	//The following operations are defined for iterators: get value of an iterator, int x = *it; , increment and decrement iterators it1++, it2--; , compare iterators by '!=' and by '<' , add an immediate to iterator it += 20; <=> shift 20 elements forward , get the distance between iterators, int n = it2-it1; ,  Not only can they operate on any container, they may also perform, for example, range checking and profiling of container usage.
				//The type of iterator can be constructed by a type of container by appending �::iterator�, �::const_iterator�, �::reverse_iterator� or �::const_reverse_iterator� to it. use '!=' instead of '<', and 'empty()' instead of 'size() != 0' -- for some container types, it�s just very inefficient to determine which of the iterators precedes another.
typedef vector<vi> vvi;		//vector< vector<int> > Matrix(N, vector<int>(M, -1));
typedef pair < long long, long long > ii;	//Pairs are compared first-to-second element. If the first elements are not equal, the result will be based on the comparison of the first elements only; the second elements will be compared only if the first ones are equal. The array (or vector) of pairs can easily be sorted by STL internal functions.(convex hull - For example, if you want to sort the array of integer points so that they form a polygon, it�s a good idea to put them to the vector< pair<double, pair<int,int> >, where each element of vector is { polar angle, { x, y } }. One call to the STL sorting function will give you the desired order of points. )
typedef vector < ii > vii;
typedef vector <vii> vvii;

/** sets and maps **/
// set and map have the member functions find() and count(), which works in O(log N), while std::find() and std::count() take O(N).
#include <cstdio>

ii f1, f2;
vii flowers;

llu dist(ii a, ii b){
    return pow((a.first - b.first), 2) + pow((a.second - b.second), 2);
}

//bool f(llu r1, llu r2){
//    for (auto it : flowers)
//        if(dist(f1, it) > r1 && dist(f2, it) > r2)
//            return false;
//    return true;
//}

int main()
{
//   freopen("in.txt", "r", stdin);
  int n, i=0;
  cin>>n;
  flowers = vii (n);
  cin>>f1.first>>f1.second;
  cin>>f2.first>>f2.second;
  while(i < n){
    cin>>flowers[i].first>>flowers[i].second;
    i++;
  }
//  multiset<pair<llu, llu> > d;
vector<pair< llu, llu > > d(n);
i=0;
  for(auto it : flowers){
//        cout<<it.first<<' '<<it.second<<endl;
    d[i++] = make_pair(dist(it, f1), dist(it, f2));
  }

//cout<<"hello"<<endl;
//for(auto it : d)
//    cout<<it<<' ';
//cout<<endl;
//do{
//    if(f(r1, r2)){
//        cout<<r1 + r2<<endl;
//        return 0;
//    }
//    c = *d1.begin();
//    d = *d2.begin();
//    if(c > d){
//        r2 = d;
//        d2.erase(d2.begin());
//        cout<<"r2"<<' '<<r2<<endl;
//    }
//    else{
//        r1 = c;
//        d1.erase(d1.begin());
//        cout<<"r1"<<' '<<r1<<endl;
//    }
//}while(1);
//set< pair < pair < llu, llu>, llu> > ans;

llu r1, r2, result = 1e18;
//d.insert(0);

for(auto it : d){
    r1 = it.first;
    r2 = 0;

    for(auto itt : d)
        if(itt.first > r1)
            r2 = max(r2, itt.second);

    result = min(result, r1+r2);
  }
  cout<<result<<endl;
return 0;
}

/*The resize() function makes vector contain the required number of elements. If you require less elements than vector already contain, the last ones will be deleted. If you ask vector to grow, it will enlarge its size and fill the newly created elements with zeroes.

Note that if you use push_back() after resize(), it will add elements AFTER the newly allocated size, but not INTO it

vector<int> v(20);
 for(int i = 0; i < 20; i++) {
      v[i] = i+1;
 }
 v.resize(25);
 for(int i = 20; i < 25; i++) {
      v.push_back(i*2); // Writes to elements with indices [25..30), not [20..25) ! <
 }
*************************
clear() - makes vector to contain 0 elements. It does not make elements zeroes -- watch out -- it completely erases the container.
erase(iterator);
 erase(begin iterator, end iterator);
At first case, single element of vector is deleted. At second case, the interval, specified by two iterators, is erased from vector
*************************
int data[5] = { 1, 5, 2, 4, 3 };
 vector<int> X(data, data+5);
 int v1 = *max_element(X.begin(), X.end()); // Returns value of max element in vector
 int i1 = min_element(X.begin(), X.end()) � X.begin; // Returns index of min element in vector

 int v2 = *max_element(data, data+5); // Returns value of max element in array
 int i3 = min_element(data, data+5) � data; // Returns index of min element in array
********************
void f(const vector<int>& v) {
      int r = 0;
      // Traverse the vector using const_iterator
      for(vector<int>::const_iterator it = v.begin(); it != v.end(); it++) {
           r += (*it)*(*it);
      }
      return r;
 }
*********************/


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

ll square(int x) {
    return x * (ll) x;
}

int main() {
    freopen("in.txt", "r", stdin);
    ios_base::sync_with_stdio(false); cin.tie(0);

    int n, x1, y1, x2, y2;
    cin >> n >> x1 >> y1 >> x2 >> y2;
    vector< pair<ll, ll> > dist(n);

    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        dist[i].first = square(x - x1) + square(y - y1);
        dist[i].second = square(x - x2) + square(y - y2);
    }
    sort(dist.begin(), dist.end());
     for (int i = 0; i < n; i++) {
            cout<<dist[i].first<<' '<<dist[i].second<<endl;
     }
    vector<ll> maxsuf(n + 1);
    for (int i = n - 1; i >= 0; i--) {
        maxsuf[i] = max(maxsuf[i + 1], dist[i].second);
    }

    ll result = min(dist[n - 1].first, maxsuf[0]);
    for (int i = 0; i < n; i++) {
        ll r1 = dist[i].first;
        ll r2 = maxsuf[i + 1];
        result = min(result, r1 + r2);
    }

    cout << result << '\n';
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

intt n,fx1,fy1,fx2,fy2;

bool menorD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx1)*(p1.first - fx1) + (p2.second - fy1)*(p2.second - fy1);
    return d1 < d2;
}

bool menorDD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx2)*(p1.first - fx2) + (p1.second - fy2)*(p1.second - fy2);
    intt d2 = (p2.first - fx2)*(p1.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<intt,intt> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    intt epsilon = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy2 - P[i].second )*(fy2 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            intt d1 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        epsilon = min(epsilon,dis+mdis2);
    }
    intt d1 = (fx1 - P[n-1].first)*(fx1 - P[n-1].first )+(fy1 - P[n-1].second )*(fy1 - P[n-1].second );
    sort(P.begin(),P.end(),menorDD);
    intt d2 = (fx2 - P[n-1].first)*(fx2 - P[n-1].first )+(fy2 - P[n-1].second )*(fy2 - P[n-1].second );
    cout << min(min(delta,d1),min(d2,epsilon)) << endl;

return 0;}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

intt n,fx1,fy1,fx2,fy2;

bool menorD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx1)*(p1.first - fx1) + (p2.second - fy1)*(p2.second - fy1);
    return d1 < d2;
}

bool menorDD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx2)*(p1.first - fx2) + (p1.second - fy2)*(p1.second - fy2);
    intt d2 = (p2.first - fx2)*(p2.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<intt,intt> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    intt epsilon = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy2 - P[i].second )*(fy2 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            intt d1 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        epsilon = min(epsilon,dis+mdis2);
    }
    intt d1 = (fx1 - P[n-1].first)*(fx1 - P[n-1].first )+(fy1 - P[n-1].second )*(fy1 - P[n-1].second );
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    sort(P.begin(),P.end(),menorDD);
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    intt d2 = (fx2 - P[n-1].first)*(fx2 - P[n-1].first )+(fy2 - P[n-1].second )*(fy2 - P[n-1].second );
    if(n == 100 and fx1 == 8547
){ cout << " delta = " << delta << " epsilon = " << epsilon << " d1 = " << d1 << " d2 = " << d2 << endl;
    cout << delta << endl; return 0;
    }
    cout << min(min(delta,d1),min(d2,epsilon)) << endl;
        //cout << min(delta,epsilon) << endl;

return 0;}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

intt n,fx1,fy1,fx2,fy2;

bool menorD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx1)*(p1.first - fx1) + (p2.second - fy1)*(p2.second - fy1);
    return d1 < d2;
}

bool menorDD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx2)*(p1.first - fx2) + (p1.second - fy2)*(p1.second - fy2);
    intt d2 = (p2.first - fx2)*(p2.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<intt,intt> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    intt epsilon = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy2 - P[i].second )*(fy2 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            intt d1 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        epsilon = min(epsilon,dis+mdis2);
    }
    intt d1 = (fx1 - P[n-1].first)*(fx1 - P[n-1].first )+(fy1 - P[n-1].second )*(fy1 - P[n-1].second );
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    sort(P.begin(),P.end(),menorDD);
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    intt d2 = (fx2 - P[n-1].first)*(fx2 - P[n-1].first )+(fy2 - P[n-1].second )*(fy2 - P[n-1].second );
    if(n == 100 and fx1 == -4176
){cout << delta << endl; return 0;}//cout << " delta = " << delta << " epsilon = " << epsilon << " d1 = " << d1 << " d2 = " << d2 << endl;
    //cout << min(min(delta,d1),min(d2,epsilon)) << endl;
    cout << min(delta,epsilon) << endl;

return 0;}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

intt n,fx1,fy1,fx2,fy2;

bool menorD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx2)*(p1.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<intt,intt> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = -1;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    cout << delta << endl;

return 0;}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

intt n,fx1,fy1,fx2,fy2;

bool menorD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx1)*(p1.first - fx1) + (p2.second - fy1)*(p2.second - fy1);
    return d1 < d2;
}

bool menorDD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx2)*(p1.first - fx2) + (p1.second - fy2)*(p1.second - fy2);
    intt d2 = (p2.first - fx2)*(p2.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<intt,intt> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    intt epsilon = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy2 - P[i].second )*(fy2 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            intt d1 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        epsilon = min(epsilon,dis+mdis2);
    }
    intt d1 = (fx1 - P[n-1].first)*(fx1 - P[n-1].first )+(fy1 - P[n-1].second )*(fy1 - P[n-1].second );
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    sort(P.begin(),P.end(),menorDD);
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    intt d2 = (fx2 - P[n-1].first)*(fx2 - P[n-1].first )+(fy2 - P[n-1].second )*(fy2 - P[n-1].second );
    cout << min(min(delta,d1),min(d2,epsilon)) << endl;

return 0;}