#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define mod 	1000000007
#define mp make_pair
#define inf 	1e18
#define pb  	push_back
#define full(x) x.begin(), x.end()
#define int 	long long
#define pq 	priority_queue<int,int>
#define ford(i, a, b) for (int i=a; i<(b); i++)
#define foro(i, a) for (int i=0; i<(a); i++)
#define w(t)	int t; cin>>t; while(t--)

const int N = 1e5 ;

using namespace std;

#define IOS ios:: sync_with_stdio(0);cin.tie(0); cout.tie(0);

void abc()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<int> primesieve(int *p, int n)
{
	p[0] = p[1] = 0;
	p[2] = 1;

	for (int i = 3; i <= n; i++)
	{
		p[i] = 1;
	}

	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1 )
		{
			for (int j = i * i; j <= n; j += 2 * i)
			{
				p[j] = 0;
			}
		}
	}

	vector<int> primes;
	primes.pb(2);
	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1)
		{
			primes.pb(i);
		}
	}

	return primes;
}

vector<pair<int, int>> findingdivisor(vector<int> &primes, int n)
{
	vector<pair<int, int>> div;
	for (int i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			int cnt = 0;

			while (n % i == 0)
			{
				n = n / i;
				cnt++;
			}
			div.pb(mp(i, cnt));

		}
	}

	if (n != 1)
	{
		div.pb(mp(n, 1));
	}

	return div;
}
int32_t main()
{
	IOS;

	int p[N];

	for (int i = 0; i < N; i++)
	{
		p[i] = 0;
	}
	w(t)
	{
		int n;
		cin >> n;
		vector <int> prime = primesieve(p, N);

		vector<pair<int, int>> dila = findingdivisor(prime, n);
		if (dila.size() >= 3)
		{
			cout << "YES" << endl;
			int mu = 1;
			for (int i = 0; i < 2; i++)
			{
				mu *= dila[i].first;
				cout << dila[i].first << " ";
			}
			int th = n / mu;
			cout << th << endl;

		}
		if (dila.size() == 2)
		{
			int mul = 1;
			for (auto h : dila)
			{
				mul *= h.first;
			}

			int third = n / mul;

			if (third == dila[0].first or third == dila[1].first or third < 2)
			{

				cout << "NO" << endl;
			}
			else if (third < dila[1].first)
			{

				cout << "YES" << endl;

				cout << dila[0].first << " " << third << " " << dila[1].first;

				cout << endl;

			}
			else
			{
				cout << "YES" << endl;
				cout << dila[0].first << " " << dila[1].first << " " << third;
				cout << endl;

			}

		}
		if (dila.size() == 1)
		{
			for (auto b : dila)
			{
				if (b.second >= 6)
				{
					cout << "YES" << endl;
					cout << b.first << " " << b.first*b.first << " " << b.first*b.first*b.first << endl;
				}
				else {
					cout << "NO" << endl;
				}

			}
		}

	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define mod 	1000000007
#define mp make_pair
#define inf 	1e18
#define pb  	push_back
#define full(x) x.begin(), x.end()
#define int 	long long
#define pq 	priority_queue<int,int>
#define ford(i, a, b) for (int i=a; i<(b); i++)
#define foro(i, a) for (int i=0; i<(a); i++)
#define w(t)	int t; cin>>t; while(t--)

const int N = 1e5 ;

using namespace std;

#define IOS ios:: sync_with_stdio(0);cin.tie(0); cout.tie(0);

void abc()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<int> primesieve(int *p, int n)
{
	p[0] = p[1] = 0;
	p[2] = 1;

	for (int i = 3; i <= n; i++)
	{
		p[i] = 1;
	}

	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1 )
		{
			for (int j = i * i; j <= n; j += 2 * i)
			{
				p[j] = 0;
			}
		}
	}

	vector<int> primes;
	primes.pb(2);
	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1)
		{
			primes.pb(i);
		}
	}

	return primes;
}

vector<pair<int, int>> findingdivisor(vector<int> &primes, int n)
{
	vector<pair<int, int>> div;
	for (int i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			int cnt = 0;

			while (n % i == 0)
			{
				n = n / i;
				cnt++;
			}
			div.pb(mp(i, cnt));

		}
	}

	if (n != 1)
	{
		div.pb(mp(n, 1));
	}

	return div;
}
int32_t main()
{
	IOS;

	int p[N];

	for (int i = 0; i < N; i++)
	{
		p[i] = 0;
	}
	w(t)
	{
		int n;
		cin >> n;
		vector <int> prime = primesieve(p, N);

		vector<pair<int, int>> dila = findingdivisor(prime, n);
		if (dila.size() >= 3)
		{
			cout << "YES" << endl;

			for (int i = 0; i < 3; i++)
			{
				cout << dila[i].first << " ";
			}
			cout << endl;
		}
		if (dila.size() == 2)
		{
			int mul = 1;
			for (auto h : dila)
			{
				mul *= h.first;
			}

			int third = n / mul;

			if (third == dila[0].first or third == dila[1].first)
			{
				cout << "NO" << endl;
			}
			else
			{
				cout << "YES" << endl;
				cout << dila[0].first << " " << dila[1].first << " " << third << endl;
			}
		}
		if (dila.size() == 1)
		{
			for (auto b : dila)
			{
				if (b.second >= 6)
				{
					cout << "YES" << endl;
					cout << b.first << " " << b.first*b.first << " " << b.first*b.first*b.first << endl;
				}
				else {
					cout << "NO" << endl;
				}

			}
		}

	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define mod 	1000000007
#define mp make_pair
#define inf 	1e18
#define pb  	push_back
#define full(x) x.begin(), x.end()
#define int 	long long
#define pq 	priority_queue<int,int>
#define ford(i, a, b) for (int i=a; i<(b); i++)
#define foro(i, a) for (int i=0; i<(a); i++)
#define w(t)	int t; cin>>t; while(t--)

const int N = 1e5 + 5;

using namespace std;

#define IOS ios:: sync_with_stdio(0);cin.tie(0); cout.tie(0);

void abc()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<int> primesieve(int *p, int n)
{
	p[0] = p[1] = 0;
	p[2] = 1;

	for (int i = 3; i <= n; i++)
	{
		p[i] = 1;
	}

	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1 )
		{
			for (int j = i * i; j <= n; j += 2 * i)
			{
				p[j] = 0;
			}
		}
	}

	vector<int> primes;
	primes.pb(2);
	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1)
		{
			primes.pb(i);
		}
	}

	return primes;
}

vector<pair<int, int>> findingdivisor(vector<int> &primes, int n)
{
	vector<pair<int, int>> div;
	for (int i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			int cnt = 0;

			while (n % i == 0)
			{
				n = n / i;
				cnt++;
			}
			div.pb(mp(i, cnt));

		}
	}

	if (n != 1)
	{
		div.pb(mp(n, 1));
	}

	return div;
}
int32_t main()
{
	IOS;

	int p[N];

	for (int i = 0; i < N; i++)
	{
		p[i] = 0;
	}
	w(t)
	{
		int n;
		cin >> n;
		vector <int> prime = primesieve(p, N);

		vector<pair<int, int>> dila = findingdivisor(prime, n);
		if (dila.size() >= 3)
		{
			cout << "YES" << endl;

			for (int i = 0; i < 3; i++)
			{
				cout << dila[i].first << " ";
			}
			cout << endl;
		}
		else if (dila.size() == 2)
		{
			cout << "NO" << endl;
		}
		else if (dila.size() == 1)
		{
			for (auto b : dila)
			{
				if (b.second >= 6)
				{
					cout << "YES" << endl;
					cout << b.first << " " << b.first*b.first << " " << b.first*b.first*b.first << endl;
				}
				else {
					cout << "NO" << endl;
				}

			}
		}

	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define mod 	1000000007
#define mp make_pair
#define inf 	1e18
#define pb  	push_back
#define full(x) x.begin(), x.end()
#define int 	long long
#define pq 	priority_queue<int,int>
#define ford(i, a, b) for (int i=a; i<(b); i++)
#define foro(i, a) for (int i=0; i<(a); i++)
#define w(t)	int t; cin>>t; while(t--)

const int N = 1e5 ;

using namespace std;

#define IOS ios:: sync_with_stdio(0);cin.tie(0); cout.tie(0);

void abc()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<int> primesieve(int *p, int n)
{
	p[0] = p[1] = 0;
	p[2] = 1;

	for (int i = 3; i <= n; i++)
	{
		p[i] = 1;
	}

	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1 )
		{
			for (int j = i * i; j <= n; j += 2 * i)
			{
				p[j] = 0;
			}
		}
	}

	vector<int> primes;
	primes.pb(2);
	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1)
		{
			primes.pb(i);
		}
	}

	return primes;
}

vector<pair<int, int>> findingdivisor(vector<int> &primes, int n)
{
	vector<pair<int, int>> div;
	for (int i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			int cnt = 0;

			while (n % i == 0)
			{
				n = n / i;
				cnt++;
			}
			div.pb(mp(i, cnt));

		}
	}

	if (n != 1)
	{
		div.pb(mp(n, 1));
	}

	return div;
}
int32_t main()
{
	IOS;

	int p[N];

	for (int i = 0; i < N; i++)
	{
		p[i] = 0;
	}
	w(t)
	{
		int n;
		cin >> n;
		vector <int> prime = primesieve(p, N);

		vector<pair<int, int>> dila = findingdivisor(prime, n);
		if (dila.size() >= 3)
		{
			cout << "YES" << endl;

			for (int i = 0; i < 3; i++)
			{
				cout << dila[i].first << " ";
			}
			cout << endl;
		}
		if (dila.size() == 2)
		{
			int mul = 1;
			for (auto h : dila)
			{
				mul *= h.first;
			}

			int third = n / mul;

			if (third == dila[0].first or third == dila[1].first or third < 2)
			{
				cout << "NO" << endl;
			}
			else if (dila[0].first < dila[1].first < third)
			{
				cout << "YES" << endl;
				cout << dila[0].first << " " << dila[1].first << " " << third << endl;
			}
		}
		if (dila.size() == 1)
		{
			for (auto b : dila)
			{
				if (b.second >= 6)
				{
					cout << "YES" << endl;
					cout << b.first << " " << b.first*b.first << " " << b.first*b.first*b.first << endl;
				}
				else {
					cout << "NO" << endl;
				}

			}
		}

	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define mod 	1000000007
#define mp make_pair
#define inf 	1e18
#define pb  	push_back
#define full(x) x.begin(), x.end()
#define int 	long long
#define pq 	priority_queue<int,int>
#define ford(i, a, b) for (int i=a; i<(b); i++)
#define foro(i, a) for (int i=0; i<(a); i++)
#define w(t)	int t; cin>>t; while(t--)

const int N = 1e5 + 5;

using namespace std;

#define IOS ios:: sync_with_stdio(0);cin.tie(0); cout.tie(0);

void abc()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<int> primesieve(int *p, int n)
{
	p[0] = p[1] = 0;
	p[2] = 1;

	for (int i = 3; i <= n; i++)
	{
		p[i] = 1;
	}

	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1 )
		{
			for (int j = i * i; j <= n; j += 2 * i)
			{
				p[j] = 0;
			}
		}
	}

	vector<int> primes;
	primes.pb(2);
	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1)
		{
			primes.pb(i);
		}
	}

	return primes;
}

vector<pair<int, int>> findingdivisor(vector<int> &primes, int n)
{
	vector<pair<int, int>> div;
	for (int i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			int cnt = 0;

			while (n % i == 0)
			{
				n = n / i;
				cnt++;
			}
			div.pb(mp(i, cnt));

		}
	}

	if (n != 1)
	{
		div.pb(mp(n, 1));
	}

	return div;
}
int32_t main()
{
	IOS;

	int p[N];

	for (int i = 0; i < N; i++)
	{
		p[i] = 0;
	}
	w(t)
	{
		int n;
		cin >> n;
		vector <int> prime = primesieve(p, N);

		vector<pair<int, int>> dila = findingdivisor(prime, n);
		if (dila.size() >= 3)
		{
			cout << "YES" << endl;

			for (auto h : dila)
			{
				cout << h.first << " ";
			}
			cout << endl;
		}
		else if (dila.size() == 2)
		{
			cout << "NO" << endl;
		}
		else if (dila.size() == 1)
		{
			for (auto b : dila)
			{
				if (b.second >= 6)
				{
					cout << "YES" << endl;
					cout << b.first << " " << b.first*b.first << " " << b.first*b.first*b.first << endl;
				}
				else {
					cout << "NO" << endl;
				}

			}
		}

	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define mod 	1000000007
#define mp make_pair
#define inf 	1e18
#define pb  	push_back
#define full(x) x.begin(), x.end()
#define int 	long long
#define pq 	priority_queue<int,int>
#define ford(i, a, b) for (int i=a; i<(b); i++)
#define foro(i, a) for (int i=0; i<(a); i++)
#define w(t)	int t; cin>>t; while(t--)

const int N = 1e5 + 5;

using namespace std;

#define IOS ios:: sync_with_stdio(0);cin.tie(0); cout.tie(0);

void abc()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<int> primesieve(int *p, int n)
{
	p[0] = p[1] = 0;
	p[2] = 1;

	for (int i = 3; i <= n; i++)
	{
		p[i] = 1;
	}

	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1 )
		{
			for (int j = i * i; j <= n; j += 2 * i)
			{
				p[j] = 0;
			}
		}
	}

	vector<int> primes;
	primes.pb(2);
	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1)
		{
			primes.pb(i);
		}
	}

	return primes;
}

vector<pair<int, int>> findingdivisor(vector<int> &primes, int n)
{
	vector<pair<int, int>> div;
	for (int i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			int cnt = 0;

			while (n % i == 0)
			{
				n = n / i;
				cnt++;
			}
			div.pb(mp(i, cnt));

		}
	}

	if (n != 1)
	{
		div.pb(mp(n, 1));
	}

	return div;
}
int32_t main()
{
	IOS;

	int p[N];

	for (int i = 0; i < N; i++)
	{
		p[i] = 0;
	}
	w(t)
	{
		int n;
		cin >> n;
		vector <int> prime = primesieve(p, N);

		vector<pair<int, int>> dila = findingdivisor(prime, n);
		if (dila.size() >= 3)
		{
			cout << "YES" << endl;

			for (int i = 0; i < 3; i++)
			{
				cout << dila[i].first << " ";
			}
			cout << endl;
		}
		else if (dila.size() == 2)
		{
			int mul = 1;
			for (auto h : dila)
			{
				mul *= h.first;
			}

			int third = n / mul;

			if (third == dila[0].first or third == dila[1].first)
			{
				cout << "NO" << endl;
			}
			else
			{
				cout << "YES" << endl;
				cout << dila[0].first << " " << dila[1].first << " " << third << endl;
			}
		}
		else if (dila.size() == 1)
		{
			for (auto b : dila)
			{
				if (b.second >= 6)
				{
					cout << "YES" << endl;
					cout << b.first << " " << b.first*b.first << " " << b.first*b.first*b.first << endl;
				}
				else {
					cout << "NO" << endl;
				}

			}
		}

	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define mod 	1000000007
#define mp make_pair
#define inf 	1e18
#define pb  	push_back
#define full(x) x.begin(), x.end()
#define int 	long long
#define pq 	priority_queue<int,int>
#define ford(i, a, b) for (int i=a; i<(b); i++)
#define foro(i, a) for (int i=0; i<(a); i++)
#define w(t)	int t; cin>>t; while(t--)

const int N = 1e5 ;

using namespace std;

#define IOS ios:: sync_with_stdio(0);cin.tie(0); cout.tie(0);

void abc()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<int> primesieve(int *p, int n)
{
	p[0] = p[1] = 0;
	p[2] = 1;

	for (int i = 3; i <= n; i++)
	{
		p[i] = 1;
	}

	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1 )
		{
			for (int j = i * i; j <= n; j += 2 * i)
			{
				p[j] = 0;
			}
		}
	}

	vector<int> primes;
	primes.pb(2);
	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1)
		{
			primes.pb(i);
		}
	}

	return primes;
}

vector<pair<int, int>> findingdivisor(vector<int> &primes, int n)
{
	vector<pair<int, int>> div;
	for (int i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			int cnt = 0;

			while (n % i == 0)
			{
				n = n / i;
				cnt++;
			}
			div.pb(mp(i, cnt));

		}
	}

	if (n != 1)
	{
		div.pb(mp(n, 1));
	}

	return div;
}
int32_t main()
{
	IOS;

	int p[N];

	for (int i = 0; i < N; i++)
	{
		p[i] = 0;
	}
	w(t)
	{
		int n;
		cin >> n;
		vector <int> prime = primesieve(p, N);

		vector<pair<int, int>> dila = findingdivisor(prime, n);
		if (dila.size() >= 3)
		{
			cout << "YES" << endl;
			int mu = 1;
			for (int i = 0; i < 2; i++)
			{
				mu *= dila[i].first;
				cout << dila[i].first << " ";
			}
			int th = n / mu;
			cout << th << endl;

		}
		if (dila.size() == 2)
		{
			int mul = 1;
			for (auto h : dila)
			{
				mul *= h.first;
			}

			int third = n / mul;

			if (third == dila[0].first or third == dila[1].first or third < 2)
			{

				cout << "NO" << endl;
			}
			else if (third < dila[1].first)
			{

				cout << "YES" << endl;

				cout << dila[0].first << " " << third << " " << dila[1].first;

				cout << endl;

			}
			else
			{
				cout << "YES" << endl;
				cout << dila[0].first << " " << dila[1].first << " " << third;
				cout << endl;

			}

		}
		if (dila.size() == 1)
		{
			for (auto b : dila)
			{
				int y = 1;

				if (b.second >= 6)
				{
					y = dila[0].first * dila[0]. first * dila[0].first;
					int third = n / y ;
					cout << "YES" << endl;
					cout << b.first << " " << b.first*b.first << " " << third << endl;
				}
				else {
					cout << "NO" << endl;
				}

			}
		}

	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define mod 	1000000007
#define mp make_pair
#define inf 	1e18
#define pb  	push_back
#define full(x) x.begin(), x.end()
#define int 	long long
#define pq 	priority_queue<int,int>
#define ford(i, a, b) for (int i=a; i<(b); i++)
#define foro(i, a) for (int i=0; i<(a); i++)
#define w(t)	int t; cin>>t; while(t--)

const int N = 1e5 + 5;

using namespace std;

#define IOS ios:: sync_with_stdio(0);cin.tie(0); cout.tie(0);

void abc()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<int> primesieve(int *p, int n)
{
	p[0] = p[1] = 0;
	p[2] = 1;

	for (int i = 3; i <= n; i++)
	{
		p[i] = 1;
	}

	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1 )
		{
			for (int j = i * i; j <= n; j += 2 * i)
			{
				p[j] = 0;
			}
		}
	}

	vector<int> primes;
	primes.pb(2);
	for (int i = 3; i <= n; i++)
	{
		if (p[i] == 1)
		{
			primes.pb(i);
		}
	}

	return primes;
}

vector<pair<int, int>> findingdivisor(vector<int> &primes, int n)
{
	vector<pair<int, int>> div;
	for (int i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			int cnt = 0;

			while (n % i == 0)
			{
				n = n / i;
				cnt++;
			}
			div.pb(mp(i, cnt));

		}
	}

	if (n != 1)
	{
		div.pb(mp(n, 1));
	}

	return div;
}
int32_t main()
{
	IOS;

	int p[N];

	for (int i = 0; i < N; i++)
	{
		p[i] = 0;
	}
	w(t)
	{
		int n;
		cin >> n;
		vector <int> prime = primesieve(p, N);

		vector<pair<int, int>> dila = findingdivisor(prime, n);
		if (dila.size() >= 3)
		{
			cout << "YES" << endl;

			for (int i = 0; i < 3; i++)
			{
				cout << dila[i].first << " ";
			}
			cout << endl;
		}
		if (dila.size() == 2)
		{
			int mul = 1;
			for (auto h : dila)
			{
				mul *= h.first;
			}

			int third = n / mul;

			if (third == dila[0].first or third == dila[1].first)
			{
				cout << "NO" << endl;
			}
			else
			{
				cout << "YES" << endl;
				cout << dila[0].first << " " << dila[1].first << " " << third << endl;
			}
		}
		if (dila.size() == 1)
		{
			for (auto b : dila)
			{
				if (b.second >= 6)
				{
					cout << "YES" << endl;
					cout << b.first << " " << b.first*b.first << " " << b.first*b.first*b.first << endl;
				}
				else {
					cout << "NO" << endl;
				}

			}
		}

	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long  mx = -101001,mn = 101010,md;
long long d,t;

int main(){
    int n;
    cin >> n;
    while(n--){
        long long  a;
        cin >> a;
        for(int i = 2;a >= i;i++){
            if(a % i == 0)
            {
                d = i;
                break;
            }
        }
        for(int i = d + 1;a >= i;i++){
            if(a % i == 0)
            {
                t = i;
                break;
            }
        }
        if(d != 0&&t != 0&&a/(d *t) >= 2&&a/(d * t) != d&&a / (d * t) != t&&d * t * a/(d * t) == a){
        cout<<"YES"<<endl;
        cout<<d<<" "<<t<<" "<<a/(d * t)<<endl;
        }
        else cout<<"NO"<<endl;
        d = 0;
        t = 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long  mx = -101001,mn = 101010,md;
long long d,t;

int main(){
    int n;
    cin >> n;
    while(n--){
        long long  a;
        cin >> a;
        int e = a;
        for(int i = 2;a >= i;i++){
            if(a % i == 0)
            {
                d = i;
                break;
            }
        }
		if(d == 0)
        {
        	cout<<"NO"<<endl;
			continue;
		}
        e/=d;

		if (e == 0)
		e = a;
        for(int i = 2;e >= i;i++){
            if(e % i == 0&&i != d)
            {
                t = i;
                break;
            }
        }

         if(d != 0&&t != 0&&a/(d *t) >= 2&&a/(d * t) != d&&a / (d * t) != t){
		if(a % (d * t) != 0){
        cout<<"NO"<<endl;
        d = 0;
        t = 0;
     continue;
    }
        cout<<"YES"<<endl;
        cout<<d<<" "<<t<<" "<<a/(d * t)<<endl;
        }
        else cout<<"NO"<<endl;
        d = 0;
        t = 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long  mx = -101001,mn = 101010,md;
long long d,t;

int main(){
    int n;
    cin >> n;
    while(n--){
        long long  a;
        cin >> a;
        int e = a;
        for(int i = 2;a >= i;i++){
            if(a % i == 0)
            {
                d = i;
                break;
            }
        }
		if(d == 0||d == a)
        {
        	cout<<"NO"<<endl;
			continue;
		}
        e/=d;

		if (e == 0)
		e = a;
        for(int i = 2;e >= i;i++){
            if(e % i == 0&&i != d)
            {
                t = i;
                break;
            }
        }

         if(d != 0&&t != 0&&a/(d *t) >= 2&&a/(d * t) != d&&a / (d * t) != t){
		if(a % (d * t) != 0){
        cout<<"NO"<<endl;
        d = 0;
        t = 0;
     continue;
    }
        cout<<"YES"<<endl;
        cout<<d<<" "<<t<<" "<<a/(d * t)<<endl;
        }
        else cout<<"NO"<<endl;
        d = 0;
        t = 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long  mx = -101001,mn = 101010,md;
long long d,t;

int main(){
    int n;
    cin >> n;
    while(n--){
        long long  a;
        cin >> a;
        int e = a;
        for(int i = 2;a >= i;i++){
            if(a % i == 0)
            {
                d = i;
                break;
            }
        }
		if(d == 0||d == a)
        {
        	cout<<"NO"<<endl;
        	d = 0;
        	t = 0;
			continue;
		}
        e/=d;

		if (e == 0)
		e = a;
        for(int i = 2;e >= i;i++){
            if(e % i == 0&&i != d)
            {
                t = i;
                break;
            }
        }

         if(d != 0&&t != 0&&a/(d *t) >= 2&&a/(d * t) != d&&a / (d * t) != t){
		if(a % (d * t) != 0){
        cout<<"NO"<<endl;
        d = 0;
        t = 0;
     continue;
    }
        cout<<"YES"<<endl;
        cout<<d<<" "<<t<<" "<<a/(d * t)<<endl;
        }
        else cout<<"NO"<<endl;
        d = 0;
        t = 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long  mx = -101001,mn = 101010,md;
long long d,t;

int main(){
    int n;
    cin >> n;
    while(n--){
        long long  a;
        cin >> a;
        int e = a;
        for(int i = 2;a >= i;i++){
            if(a % i == 0)
            {
                d = i;
                break;
            }
        }
        e/=d;
        for(int i = 2;e >= i;i++){
            if(e % i == 0&&i != d)
            {
                t = i;
                break;
            }
        }

         if(d != 0&&t != 0&&a/(d *t) >= 2&&a/(d * t) != d&&a / (d * t) != t){
		if(a % (d * t) != 0){
        cout<<"NO"<<endl;
     continue;
    }
        cout<<"YES"<<endl;
        cout<<d<<" "<<t<<" "<<a/(d * t)<<endl;
        }
        else cout<<"NO"<<endl;
        d = 0;
        t = 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long  mx = -101001,mn = 101010,md;
long long d,t;

int main(){
    int n;
    cin >> n;
    while(n--){
        long long  a;
        cin >> a;
        int e = a;
        for(int i = 2;sqrt(a) >= i;i++){
            if(a % i == 0)
            {
                d = i;
                break;
            }
        }
		if(d == 0||d == a)
        {
        	cout<<"NO"<<endl;
        	d = 0;
        	t = 0;
			continue;
		}
        e/=d;

		if (e == 0)
		e = a;
        for(int i = d + 1;sqrt(a) >= i;i++){
            if(e % i == 0&&i != d)
            {
                t = i;
                break;
            }
        }

         if(d != 0&&t != 0&&a/(d *t) >= 2&&a/(d * t) != d&&a / (d * t) != t){
		if(a % (d * t) != 0){
        cout<<"NO"<<endl;
        d = 0;
        t = 0;
     continue;
    }
        cout<<"YES"<<endl;
        cout<<d<<" "<<t<<" "<<a/(d * t)<<endl;
        }
        else cout<<"NO"<<endl;
        d = 0;
        t = 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long  mx = -101001,mn = 101010,md;
long long d,t;

int main(){
    int n;
    cin >> n;
    while(n--){
        long long  a;
        cin >> a;
        int e = a;
        for(int i = 2;a >= i;i++){
            if(a % i == 0)
            {
                d = i;
                break;
            }
        }
        e/=d;
        for(int i = d + 1;a >= i;i++){
            if(a % i == 0)
            {
                t = i;
                break;
            }
        }

         if(d != 0&&t != 0&&a/(d *t) >= 2&&a/(d * t) != d&&a / (d * t) != t){
		if(a % (d * t) != 0){
        cout<<"NO"<<endl;
     continue;
    }
        cout<<"YES"<<endl;
        cout<<d<<" "<<t<<" "<<a/(d * t)<<endl;
        }
        else cout<<"NO"<<endl;
        d = 0;
        t = 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long  mx = -101001,mn = 101010,md;
long long d,t;

int main(){
    int n;
    cin >> n;
    while(n--){
        long long  a;
        cin >> a;
        int e = a;
        for(int i = 2;a >= i;i++){
            if(a % i == 0)
            {
                d = i;
                break;
            }
        }
        e/=d;
        for(int i = 2;a >= i;i++){
            if(e % i == 0&&i != d)
            {
                t = i;
                break;
            }
        }

         if(d != 0&&t != 0&&a/(d *t) >= 2&&a/(d * t) != d&&a / (d * t) != t){
		if(a % (d * t) != 0){
        cout<<"NO"<<endl;
     continue;
    }
        cout<<"YES"<<endl;
        cout<<d<<" "<<t<<" "<<a/(d * t)<<endl;
        }
        else cout<<"NO"<<endl;
        d = 0;
        t = 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long  mx = -101001,mn = 101010,md;
long long d,t;

int main(){
    int n;
    cin >> n;
    while(n--){
        long long  a;
        cin >> a;
        int e = a;
        for(int i = 2;a >= i;i++){
            if(a % i == 0)
            {
                d = i;
                break;
            }
        }
		if(d == 0||d == a)
        {
        	cout<<"NO"<<endl;
        	d = 0;
        	t = 0;
			continue;
		}
        e/=d;

		if (e == 0)
		e = a;
        for(int i = d + 1;e >= i;i++){
            if(e % i == 0&&i != d)
            {
                t = i;
                break;
            }
        }

         if(d != 0&&t != 0&&a/(d *t) >= 2&&a/(d * t) != d&&a / (d * t) != t){
		if(a % (d * t) != 0){
        cout<<"NO"<<endl;
        d = 0;
        t = 0;
     continue;
    }
        cout<<"YES"<<endl;
        cout<<d<<" "<<t<<" "<<a/(d * t)<<endl;
        }
        else cout<<"NO"<<endl;
        d = 0;
        t = 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long  mx = -101001,mn = 101010,md;
long long d,t;

int main(){
    int n;
    cin >> n;
    while(n--){
        long long  a;
        cin >> a;
        int e = a;
        for(int i = 2;a >= i;i++){
            if(a % i == 0)
            {
                d = i;
                break;
            }
        }
		if(d == 0)
        {
        	cout<<"NO"<<endl;
			continue;
		}
        e/=d;

		if (e == 0)
		e = a;
        for(int i = 2;e >= i;i++){
            if(e % i == 0&&i != d)
            {
                t = i;
                break;
            }
        }

         if(d != 0&&t != 0&&a/(d *t) >= 2&&a/(d * t) != d&&a / (d * t) != t){
		if(a % (d * t) != 0){
        cout<<"NO"<<endl;
     continue;
    }
        cout<<"YES"<<endl;
        cout<<d<<" "<<t<<" "<<a/(d * t)<<endl;
        }
        else cout<<"NO"<<endl;
        d = 0;
        t = 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long  mx = -101001,mn = 101010,md;
long long d,t;

int main(){
    int n;
    cin >> n;
    while(n--){
        long long  a;
        cin >> a;
        int e = a;
        for(int i = 2;a >= i;i++){
            if(a % i == 0)
            {
                d = i;
                break;
            }
        }
        e/=d;
        if(d == 0)
        {
        	cout<<"NO"<<endl;
			continue;
		}
		if (e == 0)
		e = a;
        for(int i = 2;e >= i;i++){
            if(e % i == 0&&i != d)
            {
                t = i;
                break;
            }
        }

         if(d != 0&&t != 0&&a/(d *t) >= 2&&a/(d * t) != d&&a / (d * t) != t){
		if(a % (d * t) != 0){
        cout<<"NO"<<endl;
     continue;
    }
        cout<<"YES"<<endl;
        cout<<d<<" "<<t<<" "<<a/(d * t)<<endl;
        }
        else cout<<"NO"<<endl;
        d = 0;
        t = 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long  mx = -101001,mn = 101010,md;
long long d,t;

int main(){
    int n;
    cin >> n;
    while(n--){
        long long  a;
        cin >> a;
        int e = a;
        for(int i = 2;a >= i;i++){
            if(a % i == 0)
            {
                d = i;
                break;
            }
        }
        e/=d;
        for(int i = d + 1;e >= i;i++){
            if(e % i == 0)
            {
                t = i;
                break;
            }
        }
        if(a % (d * t) != 0)
        cout<<"NO"<<endl;
        else if(d != 0&&t != 0&&a/(d *t) >= 2&&a/(d * t) != d&&a / (d * t) != t){
        cout<<"YES"<<endl;
        cout<<d<<" "<<t<<" "<<a/(d * t)<<endl;
        }
        else cout<<"NO"<<endl;
        d = 0;
        t = 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long  mx = -101001,mn = 101010,md;
long long d,t;

int main(){
    int n;
    cin >> n;
    while(n--){
        long long  a;
        cin >> a;
        int e = a;
        for(int i = 2;a >= i;i++){
            if(a % i == 0)
            {
                d = i;
                break;
            }
        }
        e/=d;
        for(int i = d + 1;a >= i;i++){
            if(a % i == 0)
            {
                t = i;
                break;
            }
        }

         if(d != 0&&t != 0&&a/(d *t) >= 2&&a/(d * t) != d&&a / (d * t) != t){
		if(a % (d * t) == 0){
        cout<<"NO"<<endl;
     continue;
    }
        cout<<"YES"<<endl;
        cout<<d<<" "<<t<<" "<<a/(d * t)<<endl;
        }
        else cout<<"NO"<<endl;
        d = 0;
        t = 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long  mx = -101001,mn = 101010,md;
int d,t;

int main(){
    int n;
    cin >> n;
    while(n--){
        long long  a;
        cin >> a;
        for(int i = 2;a >= i;i++){
            if(a % i == 0)
            {
                d = i;
                break;
            }
        }
        for(int i = d + 1;a >= i;i++){
            if(a % i == 0)
            {
                t = i;
                break;
            }
        }
        if(d != 0&&t != 0&&a/(d *t) >= 2&&a/(d * t) != d&&a / (d * t) != t&&d * t * a/(d * t) == a){
        cout<<"YES"<<endl;
        cout<<d<<" "<<t<<" "<<a/(d * t)<<endl;
        }
        else cout<<"NO"<<endl;

    }
    return 0;
}


#include<bits/stdc++.h>
#include<iostream>

#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define sz size()
#define endl "\n"
#define pb push_back
#define pp pop_back
#define mp make_pair
#define REP(I,n) for(int I = 0; I < n; I++)
#define REP_1(I,n) for(int I = 1; I <= n; I++)
#define FOR(I,A,B) for(int I = A; I < B; I++)
#define DWN(I,B,A) for(int I = B-1; I >= A; I--)
#define FOR_1(I,A,B) for(int I = A; I <= B; I++)
#define DWN_1(I,B,A) for(int I = B; I >= A; I--)
#define Read() freopen("input.txt", "r", stdin)
#define Write() freopen("output.txt", "w", stdout)
#define w(t) int t; cin>>t; while(t--)

#define ll long long
#define ull unsigned long long

#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef map<int,string> mis;
typedef set<int> si;
typedef set<string> ss;
typedef map<char,int> mci;

ll add(int arr[], int n) {
	ll sum = 0;
	REP(i,n) {
		sum += arr[i];
	}
	return sum;
}

void f_i_o() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
}
void c_r_w() {
  #ifndef ONLINE_JUDGE
 	Read();
 	Write();
  #endif
}
int main() {
	c_r_w();
	f_i_o();
	w(t) {
		int n;
		cin>>n;
		int a=-1,b=-1,c=-1;
		for(int i = 2; i <= 9; i++) {
			if(n % i == 0) {
				a = i;
				break;
			}
		}
		if(a == -1)
			cout<<"NO"<<endl;
		else {
			n = n / a;
			for(int i = 2; i <=n; i++) {
				if(i != a and n % i == 0) {
					b = i;
					break;
				}
			}
			if(b == -1)
				cout<<"NO"<<endl;
			else {
				c = n / b;
				if(c == 1 || c == -1 || b == c)
					cout<<"NO"<<endl;
				else{
					cout<<"YES"<<endl;
					cout<<a<<" "<<b<<" "<<c<<endl;
				}
			}
		}
	}

}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	 	freopen("input.txt", "r", stdin);
	 	freopen("output.txt", "w", stdout);
	#endif
	int t;
	cin>>t;
	while(t--) {
		long long n;
		cin>>n;
		long long temp=n;
		int count=0;
		int a,b,c;
		for(int i=2;i<=temp;i++) {
			if(n%i==0) {
				count++;
				if(count==1)
					a=i;
				else if(count==2)
					b=i;
				else
					c=i;
				n=n/i;
			}
			if(count==2&&b<n) {
				c=n;
				count++;
				break;
			}
		}
		if(count==3) {
			cout<<"YES"<<endl;
			cout<<a<<" "<<b<<" "<<c;
		}
		else {
			cout<<"NO";
		}
		cout<<endl;
	}
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	 	freopen("input.txt", "r", stdin);
	 	freopen("output.txt", "w", stdout);
	#endif
	int t;
	cin>>t;
	while(t--) {
		long long n;
		cin>>n;
		long long temp=n;
		int count=0;
		int a,b,c;
		for(int i=2;i<=temp;i++) {
			if(n%i==0) {
				count++;
				if(count==1)
					a=i;
				else if(count==2)
					b=i;
				else
					c=i;
				n=n/i;
			}
		}
		long long result=a*b*c;
		if(result==temp&&count==3) {
			cout<<"YES"<<endl;
			cout<<a<<" "<<b<<" "<<c;
		}
		else {
			cout<<"NO";
		}
		cout<<endl;
	}
}


#include<bits/stdc++.h>
#include<iostream>

#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define sz size()
#define endl "\n"
#define pb push_back
#define pp pop_back
#define mp make_pair
#define REP(I,n) for(int I = 0; I < n; I++)
#define REP_1(I,n) for(int I = 1; I <= n; I++)
#define FOR(I,A,B) for(int I = A; I < B; I++)
#define DWN(I,B,A) for(int I = B-1; I >= A; I--)
#define FOR_1(I,A,B) for(int I = A; I <= B; I++)
#define DWN_1(I,B,A) for(int I = B; I >= A; I--)
#define Read() freopen("input.txt", "r", stdin)
#define Write() freopen("output.txt", "w", stdout)
#define w(t) int t; cin>>t; while(t--)

#define ll long long
#define ull unsigned long long

#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef map<int,string> mis;
typedef set<int> si;
typedef set<string> ss;
typedef map<char,int> mci;

ll add(int arr[], int n) {
	ll sum = 0;
	REP(i,n) {
		sum += arr[i];
	}
	return sum;
}

void f_i_o() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
}
void c_r_w() {
  #ifndef ONLINE_JUDGE
 	Read();
 	Write();
  #endif
}
int main() {
	c_r_w();
	f_i_o();
	w(t) {
		int n;
		cin>>n;
		int a=-1,b=-1,c=-1;
		for(int i = 2; i <= 9; i++) {
			if(n % i == 0) {
				a = i;
				break;
			}
		}
		if(a == -1)
			cout<<"NO"<<endl;
		else {
			n = n / a;
			for(int i = 2; i <=n; i++) {
				if(i != a and n % i == 0) {
					b = i;
					break;
				}
			}
			if(b == -1)
				cout<<"NO"<<endl;
			else {
				c = n / b;
				if(c == 1 || c == -1 || (a == b || a == c || b == c))
					cout<<"NO"<<endl;
				else{
					cout<<"YES"<<endl;
					cout<<a<<" "<<b<<" "<<c<<endl;
					}
				}
			}
	}
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	 	freopen("input.txt", "r", stdin);
	 	freopen("output.txt", "w", stdout);
	#endif
	int t;
	cin>>t;
	while(t--) {
		int n;
		cin>>n;
		int temp=n;
		vector<int> v;
		for(int i=2;i<=n;i++) {
			if(n%i==0) {
				v.push_back(i);
				n=n/i;
			}
		}
		if(v.size()==3) {
			cout<<"YES"<<"\n";
			for(auto x:v)
				cout<<x<<" ";
		}
		else {
			cout<<"NO";
		}
		cout<<"\n";
	}
}


#include<bits/stdc++.h>
#include<iostream>

#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define sz size()
#define endl "\n"
#define pb push_back
#define pp pop_back
#define mp make_pair
#define REP(I,n) for(int I = 0; I < n; I++)
#define REP_1(I,n) for(int I = 1; I <= n; I++)
#define FOR(I,A,B) for(int I = A; I < B; I++)
#define DWN(I,B,A) for(int I = B-1; I >= A; I--)
#define FOR_1(I,A,B) for(int I = A; I <= B; I++)
#define DWN_1(I,B,A) for(int I = B; I >= A; I--)
#define Read() freopen("input.txt", "r", stdin)
#define Write() freopen("output.txt", "w", stdout)
#define w(t) int t; cin>>t; while(t--)

#define ll long long
#define ull unsigned long long

#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef map<int,string> mis;
typedef set<int> si;
typedef set<string> ss;
typedef map<char,int> mci;

ll add(int arr[], int n) {
	ll sum = 0;
	REP(i,n) {
		sum += arr[i];
	}
	return sum;
}

void f_i_o() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
}
void c_r_w() {
  #ifndef ONLINE_JUDGE
 	Read();
 	Write();
  #endif
}
int main() {
	c_r_w();
	f_i_o();
	w(t) {
		int n;
		cin>>n;
		int a[3] = {0};
		int c = 0;
		for(int i = 2; c<2 && i*i < n; i++) {
			if(n % i == 0) {
				a[c++] = i;
				n = n / i;
			}
		}
		if(c == 2)
			cout<<"YES"<<endl<<a[0]<<" "<<a[1]<<" "<<n<<endl;
		else
			cout<<"NO"<<endl;
	}
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	 	freopen("input.txt", "r", stdin);
	 	freopen("output.txt", "w", stdout);
	#endif
	int t;
	cin>>t;
	while(t--) {
		int n;
		cin>>n;
		int temp=n;
		int count=0;
		int a,b,c;
		for(int i=2;i<=temp;i++) {
			if(n%i==0) {
				count++;
				if(count==1)
					a=i;
				else if(count==2)
					b=i;
				else
					c=i;
				n=n/i;
			}
		}
		if(a*b*c==temp&&count==3) {
			cout<<"YES"<<endl;
			cout<<a<<" "<<b<<" "<<c;
		}
		else {
			cout<<"NO";
		}
		cout<<endl;
	}
}


#include<bits/stdc++.h>
#include<iostream>

#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define sz size()
#define endl "\n"
#define pb push_back
#define pp pop_back
#define mp make_pair
#define REP(I,n) for(int I = 0; I < n; I++)
#define REP_1(I,n) for(int I = 1; I <= n; I++)
#define FOR(I,A,B) for(int I = A; I < B; I++)
#define DWN(I,B,A) for(int I = B-1; I >= A; I--)
#define FOR_1(I,A,B) for(int I = A; I <= B; I++)
#define DWN_1(I,B,A) for(int I = B; I >= A; I--)
#define Read() freopen("input.txt", "r", stdin)
#define Write() freopen("output.txt", "w", stdout)
#define w(t) int t; cin>>t; while(t--)

#define ll long long
#define ull unsigned long long

#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef map<int,string> mis;
typedef set<int> si;
typedef set<string> ss;
typedef map<char,int> mci;

ll add(int arr[], int n) {
	ll sum = 0;
	REP(i,n) {
		sum += arr[i];
	}
	return sum;
}

void f_i_o() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
}
void c_r_w() {
  #ifndef ONLINE_JUDGE
 	Read();
 	Write();
  #endif
}
int main() {
	c_r_w();
	f_i_o();
	w(t) {
		int n;
		cin>>n;
		int a=-1,b=-1,c=-1;
		for(int i = 2; i <= n/2; i++) {
			if(n % i == 0) {
				a = i;
				break;
			}
		}
		if(a == -1)
			cout<<"NO"<<endl;
		else {
			n = n / a;
			for(int i = 2; i<=n; i++) {
				if(i != a and n % i == 0) {
					b = i;
					break;
				}
			}
			if(b == -1)
				cout<<"NO"<<endl;
			else {
				c = n / b;
				if(c == 1 || c == -1 || (a == b || a == c || b == c))
					cout<<"NO"<<endl;
				else{
					cout<<"YES"<<endl;
					cout<<a<<" "<<b<<" "<<c<<endl;
					}
				}
			}
	}
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	 	freopen("input.txt", "r", stdin);
	 	freopen("output.txt", "w", stdout);
	#endif
	int t;
	cin>>t;
	while(t--) {
		int n;
		cin>>n;
		int temp=n;
		int count=0;
		int a,b,c;
		for(int i=2;i<=temp;i++) {
			if(n%i==0) {
				count++;
				if(count==1)
					a=i;
				else if(count==2)
					b=i;
				else
					c=i;
				n=n/i;
			}
		}
		if(count==3) {
			cout<<"YES"<<endl;
			cout<<a<<" "<<b<<" "<<c;
		}
		else {
			cout<<"NO";
		}
		cout<<endl;
	}
}


#include<bits/stdc++.h>
#include<iostream>

#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define sz size()
#define endl "\n"
#define pb push_back
#define pp pop_back
#define mp make_pair
#define REP(I,n) for(int I = 0; I < n; I++)
#define REP_1(I,n) for(int I = 1; I <= n; I++)
#define FOR(I,A,B) for(int I = A; I < B; I++)
#define DWN(I,B,A) for(int I = B-1; I >= A; I--)
#define FOR_1(I,A,B) for(int I = A; I <= B; I++)
#define DWN_1(I,B,A) for(int I = B; I >= A; I--)
#define Read() freopen("input.txt", "r", stdin)
#define Write() freopen("output.txt", "w", stdout)
#define w(t) int t; cin>>t; while(t--)

#define ll long long
#define ull unsigned long long

#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef map<int,string> mis;
typedef set<int> si;
typedef set<string> ss;
typedef map<char,int> mci;

ll add(int arr[], int n) {
	ll sum = 0;
	REP(i,n) {
		sum += arr[i];
	}
	return sum;
}

void f_i_o() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
}
void c_r_w() {
  #ifndef ONLINE_JUDGE
 	Read();
 	Write();
  #endif
}
int main() {
	c_r_w();
	f_i_o();
	w(t) {
		int n;
		cin>>n;
		int a=-1,b=-1,c=-1;
		for(int i = 2; i <= 9; i++) {
			if(n % i == 0) {
				a = i;
				break;
			}
		}
		if(a == -1)
			cout<<"NO"<<endl;
		else {
			n = n / a;
			for(int i = 2; i <=n; i++) {
				if(i != a and n % i == 0) {
					b = i;
					break;
				}
			}
			if(b == -1)
				cout<<"NO"<<endl;
			else {
				c = n / b;
				if(c == -1 || b == c)
					cout<<"NO"<<endl;
				else{
					cout<<"YES"<<endl;
					cout<<a<<" "<<b<<" "<<c<<endl;
				}
			}
		}
	}

}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	 	freopen("input.txt", "r", stdin);
	 	freopen("output.txt", "w", stdout);
	#endif
	int t;
	cin>>t;
	while(t--) {
		int n;
		cin>>n;
		int temp=n;
		vector<int> v;
		for(int i=2;i<=temp;i++) {
			if(n%i==0) {
				v.push_back(i);
				n=n/i;
			}
		}
		if(v.size()==3) {
			cout<<"YES"<<"\n";
			for(auto x:v)
				cout<<x<<" ";
		}
		else {
			cout<<"NO";
		}
		cout<<"\n";
	}
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	 	freopen("input.txt", "r", stdin);
	 	freopen("output.txt", "w", stdout);
	#endif
	int t;
	cin>>t;
	while(t--) {
		long long n;
		cin>>n;
		long long temp=n;
		int count=0;
		int a,b,c;
		for(int i=2;i<=temp;i++) {
			if(n%i==0) {
				count++;
				if(count==1)
					a=i;
				else if(count==2)
					b=i;
				else
					c=i;
				n=n/i;
			}
			if(n==0)
				break;
		}
		if(count==3) {
			cout<<"YES"<<endl;
			cout<<a<<" "<<b<<" "<<c;
		}
		else {
			cout<<"NO";
		}
		cout<<endl;
	}
}


#include<bits/stdc++.h>
#include<iostream>

#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define sz size()
#define endl "\n"
#define pb push_back
#define pp pop_back
#define mp make_pair
#define REP(I,n) for(int I = 0; I < n; I++)
#define REP_1(I,n) for(int I = 1; I <= n; I++)
#define FOR(I,A,B) for(int I = A; I < B; I++)
#define DWN(I,B,A) for(int I = B-1; I >= A; I--)
#define FOR_1(I,A,B) for(int I = A; I <= B; I++)
#define DWN_1(I,B,A) for(int I = B; I >= A; I--)
#define Read() freopen("input.txt", "r", stdin)
#define Write() freopen("output.txt", "w", stdout)
#define w(t) int t; cin>>t; while(t--)

#define ll long long
#define ull unsigned long long

#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef map<int,string> mis;
typedef set<int> si;
typedef set<string> ss;
typedef map<char,int> mci;

ll add(int arr[], int n) {
	ll sum = 0;
	REP(i,n) {
		sum += arr[i];
	}
	return sum;
}

void f_i_o() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
}
void c_r_w() {
  #ifndef ONLINE_JUDGE
 	Read();
 	Write();
  #endif
}
int main() {
	c_r_w();
	f_i_o();
	w(t) {
		int n;
		cin>>n;
		int a=-1,b=-1,c=-1;
		for(int i = 2; i <= 9; i++) {
			if(n % i == 0) {
				a = i;
				break;
			}
		}
		if(a == -1)
			cout<<"NO"<<endl;
		else {
			n = n / a;
			for(int i = 2; i*i <=n; i++) {
				if(i != a and n % i == 0) {
					b = i;
					break;
				}
			}
			if(b == -1)
				cout<<"NO"<<endl;
			else {
				c = n / b;
				if(c == 1 || c == -1 || (a == b || a == c || b == c))
					cout<<"NO"<<endl;
				else{
					cout<<"YES"<<endl;
					cout<<a<<" "<<b<<" "<<c<<endl;
					}
				}
			}
	}
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	 	freopen("input.txt", "r", stdin);
	 	freopen("output.txt", "w", stdout);
	#endif
	int t;
	cin>>t;
	while(t--) {
		long long n;
		cin>>n;
		long long temp=n;
		int count=0;
		int a,b,c;
		for(int i=2;i<=temp;i++) {
			if(n%i==0) {
				count++;
				if(count==1)
					a=i;
				else if(count==2)
					b=i;
				else
					c=i;
				n=n/i;
			}
			if(count==2&&b!=n) {
				c=n;
				count++;
				break;
			}
		}
		if(count==3) {
			cout<<"YES"<<endl;
			cout<<a<<" "<<b<<" "<<c;
		}
		else {
			cout<<"NO";
		}
		cout<<endl;
	}
}


//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef unsigned long long ull;
typedef long long  ll;
#define MOD 1000000007
#define MX 1000000000
#define PI 3.14159265
#define pb push_back
using namespace std;
#define sc second
#define endl '\n'
#define fr first
vector<ll> vec;

void primeFactors(ll n)
{
    vec.clear();
    while (n % 2 == 0)
    {
        vec.pb(2);
        n = n/2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            vec.pb(i);
            n = n/i;
        }
    }
    if (n > 2)
    {
        vec.pb(n);
    }
}
int main() {
    startt
    int t;
    cin >> t;
    while(t--)
    {
        ll n;
        cin >> n;
        primeFactors(n);
        if(vec.size() < 3)
        {
            cout << "NO" << endl;
        }
        else
        {
            set<ll> s;
            for(ll i = 0; i < vec.size(); i++)
            {
                s.insert(vec[i]);
            }
            if(vec.size() == 3 && s.size() < 3)
            {
                cout << "NO" << endl;
                continue;
            }
            if(vec.size() == 3)
            {
                cout << "YES" << endl;
                cout << vec[0] << " " << vec[1] << " " << vec[2] << endl;
                continue;
            }
            if(s.size() == 1)
            {
                if(vec.size() < 6 )
                {
                    cout << "NO" << endl;;
                }
                else
                {
                    cout << "YES" << endl;
                    ll a = vec[0], b = vec[1]*vec[2], c = 1;
                    for(ll i = 3; i < vec.size(); i++)
                    {
                        c*=vec[i];
                    }
                    cout << a << " " << b << " " << c << endl;
                }
                continue;
            }
            if(vec[0] == vec[1])
            {
                ll a = vec[0], b = vec[1]*vec[2], c = 1;
                for(ll i = 3; i < vec.size(); i++)
                {
                    c*=vec[i];
                }
                cout << "YES" << endl;
                cout << a << " " << b << " " << c << endl;
            }
            else
            {
                ll a = vec[0], b = vec[1], c = 1;
                for(ll i = 2; i < vec.size(); i++)
                {
                    c*=vec[i];
                }
                cout << "YES" << endl;
                cout << a << " " << b << " " << c << endl;
            }
        }
    }
}


//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef unsigned long long ull;
typedef long long  ll;
#define MOD 1000000007
#define MX 1000000000
#define PI 3.14159265
#define pb push_back
using namespace std;
#define sc second
#define endl '\n'
#define fr first
vector<ll> vec;

void primeFactors(ll n)
{
    vec.clear();
    while (n % 2 == 0)
    {
        vec.pb(2);
        n = n/2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            vec.pb(i);
            n = n/i;
        }
    }
    if (n > 2)
    {
        vec.pb(n);
    }
}
int main() {
    startt
    int t;
    cin >> t;
    while(t--)
    {
        ll n;
        cin >> n;
        primeFactors(n);
        if(vec.size() < 3)
        {
            cout << "NO" << endl;
        }
        else
        {
            set<ll> s;
            for(ll i = 0; i < vec.size(); i++)
            {
                s.insert(vec[i]);
            }
            if(vec.size() == 3 && (vec[0] == vec[1] || vec[1] == vec[2] || vec[0] == vec[2]))
            {
                cout << "NO" << endl;
                continue;
            }
            if(vec.size() == 3)
            {
                cout << "YES" << endl;
                cout << vec[0] << " " << vec[1] << " " << vec[2] << endl;
                continue;
            }
            if(vec.size() == 4)
            {
                if(s.size() <= 1)
                {
                    cout << "NO" << endl;
                }
                else
                {
                    cout << "YES" << endl;
                    cout << vec[0] << " " << vec[1]*vec[2] << " " << vec[3] << endl;
                }
                continue;
            }
            if(vec.size() == 5)
            {
                if(s.size() <= 1)
                {
                    cout << "NO" << endl;
                }
                else
                {
                    cout << "YES" << endl;
                    cout << vec[0] << " " << vec[1]*vec[2]*vec[3] << " " << vec[5] << endl;
                }
                continue;
            }
            cout << "YES" << endl;
            ll a = vec[0], b = 1, c = vec[vec.size()-1]*vec[vec.size()-2];
            for(ll i = 1; i < vec.size()-2; i++)
            {
                b*=vec[i];
            }
            cout << a << " " << b << " " << c << endl;
        }
    }
}


//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef unsigned long long ull;
typedef long long  ll;
#define MOD 1000000007
#define MX 1000000000
#define PI 3.14159265
#define pb push_back
using namespace std;
#define sc second
#define endl '\n'
#define fr first
vector<ll> vec;

void primeFactors(ll n)
{
    vec.clear();
    while (n % 2 == 0)
    {
        vec.pb(2);
        n = n/2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            vec.pb(i);
            n = n/i;
        }
    }
    if (n > 2)
    {
        vec.pb(n);
    }
}
int main() {
    startt
    int t;
    cin >> t;
    while(t--)
    {
        ll n;
        cin >> n;
        primeFactors(n);
        if(vec.size() < 3)
        {
            cout << "NO" << endl;
        }
        else
        {
            set<ll> s;
            for(ll i = 0; i < vec.size(); i++)
            {
                s.insert(vec[i]);
            }
            if(vec.size() == 3 && s.size() < 3)
            {
                cout << "NO" << endl;
                continue;
            }
            if(vec.size() == 3)
            {
                cout << "YES" << endl;
                cout << vec[0] << " " << vec[1] << " " << vec[2] << endl;
                continue;
            }
            if(s.size() == 1)
            {
                if(vec.size() < 6 )
                {
                    cout << "NO" << endl;;
                }
                else
                {
                    cout << "YES" << endl;
                    ll a = vec[0], b = vec[1]*vec[2], c = 1;
                    for(ll i = 3; i < vec.size(); i++)
                    {
                        c*=vec[i];
                    }
                    cout << a << " " << b << " " << c << endl;
                }
                continue;
            }
            cout << "YES" << endl;
            ll a = vec[0], b = vec[1]*vec[2], c = 1;
            for(ll i = 3; i < vec.size(); i++)
            {
                c*=vec[i];
            }
            cout << a << " " << b << " " << c << endl;
        }
    }
}


//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef unsigned long long ull;
typedef long long  ll;
#define MOD 1000000007
#define MX 1000000000
#define PI 3.14159265
#define pb push_back
using namespace std;
#define sc second
#define endl '\n'
#define fr first
vector<ll> vec;

void primeFactors(ll n)
{
    vec.clear();
    while (n % 2 == 0)
    {
        vec.pb(2);
        n = n/2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            vec.pb(i);
            n = n/i;
        }
    }
    if (n > 2)
    {
        vec.pb(n);
    }
}
int main() {
    startt
    int t;
    cin >> t;
    while(t--)
    {
        ll n;
        cin >> n;
        primeFactors(n);
        if(vec.size() < 3)
        {
            cout << "NO" << endl;
        }
        else
        {
            set<ll> s;
            for(ll i = 0; i < vec.size(); i++)
            {
                s.insert(vec[i]);
            }
            if(vec.size() == 3 && s.size() < 3)
            {
                cout << "NO" << endl;
                continue;
            }
            if(vec.size() == 3)
            {
                cout << "YES" << endl;
                cout << vec[0] << " " << vec[1] << " " << vec[2] << endl;
                continue;
            }
            if(s.size() == 1)
            {
                if(vec.size() < 6 )
                {
                    cout << "NO" << endl;;
                }
                else
                {
                    cout << "YES" << endl;
                    ll a = vec[0], b = vec[1]*vec[2], c = 1;
                    for(ll i = 3; i < vec.size(); i++)
                    {
                        c*=vec[i];
                    }
                    cout << a << " " << b << " " << c << endl;
                }
                continue;
            }
            ll a = vec[0], b = vec[1]*vec[2], c = 1;
            for(ll i = 3; i < vec.size(); i++)
            {
                c*=vec[i];
            }
            if(a != b && b != c && a != c && a*b*c == n)
            {
                cout << "YES" << endl;
                cout << a << " " << b << " " << c << endl;
            }
            else
            {
                cout << "NO" << endl;
            }
        }
    }
}


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

typedef long long ll;

int primearr[4] = {1, 1 , 1 ,1};
int counter = 0;
void primeFactors(int n)
{
    while (n % 2 == 0)
    {
        primearr[counter]*=2;
        n = n/2;
        if(counter < 2 && primearr[0] != primearr[1])
        {
            counter++;
        }
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            primearr[counter]*=i;
            n = n/i;
            if(counter < 3)
            {
                counter++;
            }
        }
    }
    if (n > 2)
        primearr[counter]*=n;
}
int main()
{
    int t;
    cin >> t;
    while(t--)
    {
    int m;
    cin >> m;
    primeFactors(m);
    if(primearr[2] == 1 || primearr[1] == primearr[2])
    {
        cout << "NO" << endl;
    }
    else{
    cout << "YES" << endl;
    cout << primearr[0] << " " << primearr[1] << " " << primearr[2] << endl;
}
        primearr[0] = 1;
        primearr[1] = 1;
        primearr[2] = 1;
        primearr[3] = 1;
        counter = 0;
}
}


//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef unsigned long long ull;
typedef long long  ll;
#define MOD 1000000007
#define MX 1000000000
#define PI 3.14159265
#define pb push_back
using namespace std;
#define sc second
#define endl '\n'
#define fr first
vector<ll> vec;

void primeFactors(ll n)
{
    vec.clear();
    while (n % 2 == 0)
    {
        vec.pb(2);
        n = n/2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            vec.pb(i);
            n = n/i;
        }
    }
    if (n > 2)
    {
        vec.pb(n);
    }
}
int main() {
    startt
    int t;
    cin >> t;
    while(t--)
    {
        ll n;
        cin >> n;
        primeFactors(n);
        if(vec.size() < 3)
        {
            cout << "NO" << endl;
        }
        else
        {
            set<ll> s;
            for(ll i = 0; i < vec.size(); i++)
            {
                s.insert(vec[i]);
            }
            if(vec.size() == 3 && s.size() < 3)
            {
                cout << "NO" << endl;
                continue;
            }
            if(vec.size() == 3)
            {
                cout << "YES" << endl;
                cout << vec[0] << " " << vec[1] << " " << vec[2] << endl;
                continue;
            }
            if(s.size() == 1)
            {
                if(vec.size() < 6 )
                {
                    cout << "NO" << endl;;
                }
                else
                {
                    cout << "YES" << endl;
                    ll a = vec[0], b = vec[1]*vec[2], c = 1;
                    for(int i = 3; i < vec.size(); i++)
                    {
                        c*=vec[i];
                    }
                    cout << a << " " << b << " " << c << endl;
                }
                continue;
            }
            cout << "YES" << endl;
            ll a = vec[0], b = vec[1]*vec[2], c = 1;
            for(int i = 3; i < vec.size(); i++)
            {
                c*=vec[i];
            }
            cout << a << " " << b << " " << c << endl;
        }
    }
}


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

typedef long long ll;

int primearr[4] = {1, 1 , 1 ,1};
int counter = 0;
void primeFactors(int n)
{
    while (n % 2 == 0)
    {
        primearr[counter]*=2;
        n = n/2;
        if(counter < 2 && primearr[0] != primearr[1])
        {
            counter++;
        }
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            primearr[counter]*=i;
            n = n/i;
            if(counter < 2 && primearr[0] != primearr[1])
            {
                counter++;
            }
        }
    }
    if (n > 2)
        primearr[counter]*=n;
}
int main()
{
    int t;
    cin >> t;
    while(t--)
    {
    int m;
    cin >> m;
    primeFactors(m);
    if(primearr[2] == 1 || primearr[1] == primearr[2] || primearr[0] == primearr[2])
    {
        cout << "NO" << endl;
    }
    else{
    cout << "YES" << endl;
    cout << primearr[0] << " " << primearr[1] << " " << primearr[2] << endl;
}
        primearr[0] = 1;
        primearr[1] = 1;
        primearr[2] = 1;
        primearr[3] = 1;
        counter = 0;
}
}


//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef unsigned long long ull;
typedef long long  ll;
#define MOD 1000000007
#define MX 1000000000
#define PI 3.14159265
#define pb push_back
using namespace std;
#define sc second
#define endl '\n'
#define fr first
vector<ll> vec;

void primeFactors(ll n)
{
    vec.clear();
    while (n % 2 == 0)
    {
        vec.pb(2);
        n = n/2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            vec.pb(i);
            n = n/i;
        }
    }
    if (n > 2)
    {
        vec.pb(n);
    }
}
int main() {
    startt
    int t;
    cin >> t;
    while(t--)
    {
        ll n;
        cin >> n;
        primeFactors(n);
        if(vec.size() < 3)
        {
            cout << "NO" << endl;
        }
        else
        {
            set<ll> s;
            for(ll i = 0; i < vec.size(); i++)
            {
                s.insert(vec[i]);
            }
            if(vec.size() == 3 && (vec[0] == vec[1] || vec[1] == vec[2] || vec[0] == vec[2]))
            {
                cout << "NO" << endl;
                continue;
            }
            if(vec.size() == 3)
            {
                cout << vec[0] << " " << vec[1] << " " << vec[2] << endl;
                continue;
            }
            if(vec.size() == 4)
            {
                if(s.size() <= 1)
                {
                    cout << "NO" << endl;
                }
                else
                {
                    cout << "YES" << endl;
                    cout << vec[0] << " " << vec[1]*vec[2] << " " << vec[3] << endl;
                }
                continue;
            }
            if(vec.size() == 5)
            {
                if(s.size() <= 1)
                {
                    cout << "NO" << endl;
                }
                else
                {
                    cout << "YES" << endl;
                    cout << vec[0] << " " << vec[1]*vec[2]*vec[3] << " " << vec[5] << endl;
                }
                continue;
            }
            cout << "YES" << endl;
            ll a = vec[0], b = 1, c = vec[vec.size()-1]*vec[vec.size()-2];
            for(ll i = 1; i < vec.size()-2; i++)
            {
                b*=vec[i];
            }
            cout << a << " " << b << " " << c << endl;
        }
    }
}


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

typedef long long ll;

int primearr[4] = {1, 1 , 1 ,1};
int counter = 0;
void primeFactors(int n)
{
    while (n % 2 == 0)
    {
        primearr[counter]*=2;
        n = n/2;
        if(counter < 2 && primearr[0] != primearr[1])
        {
            counter++;
        }
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            primearr[counter]*=i;
            n = n/i;
            if(counter < 3)
            {
                counter++;
            }
        }
    }
    if (n > 2)
        primearr[counter]*=n;
}
int main()
{
    int t;
    cin >> t;
    while(t--)
    {
    int m;
    cin >> m;
    primeFactors(m);
    if(primearr[2] == 1 || primearr[1] == primearr[2] || primearr[0] == primearr[2])
    {
        cout << "NO" << endl;
    }
    else{
    cout << "YES" << endl;
    cout << primearr[0] << " " << primearr[1] << " " << primearr[2] << endl;
}
        primearr[0] = 1;
        primearr[1] = 1;
        primearr[2] = 1;
        primearr[3] = 1;
        counter = 0;
}
}


//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef unsigned long long ull;
typedef long long  ll;
#define MOD 1000000007
#define MX 1000000000
#define PI 3.14159265
#define pb push_back
using namespace std;
#define sc second
#define endl '\n'
#define fr first
vector<ll> vec;

void primeFactors(ll n)
{
    vec.clear();
    while (n % 2 == 0)
    {
        vec.pb(2);
        n = n/2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            vec.pb(i);
            n = n/i;
        }
    }
    if (n > 2)
    {
        vec.pb(n);
    }
}
int main() {
    startt
    int t;
    cin >> t;
    while(t--)
    {
        ll n;
        cin >> n;
        primeFactors(n);
        if(vec.size() < 3)
        {
            cout << "NO" << endl;
        }
        else
        {
            set<ll> s;
            for(ll i = 0; i < vec.size(); i++)
            {
                s.insert(vec[i]);
            }
            if(vec.size() == 3 && (vec[0] == vec[1] || vec[1] == vec[2] || vec[0] == vec[2]))
            {
                cout << "NO" << endl;
                continue;
            }
            if(vec.size() == 4)
            {
                if(s.size() <= 1)
                {
                    cout << "NO" << endl;
                }
                else
                {
                    cout << "YES" << endl;
                    cout << vec[0] << " " << vec[1]*vec[2] << " " << vec[3] << endl;
                }
                continue;
            }
            if(vec.size() == 5)
            {
                if(s.size() <= 1)
                {
                    cout << "NO" << endl;
                }
                else
                {
                    cout << "YES" << endl;
                    cout << vec[0] << " " << vec[1]*vec[2]*vec[3] << " " << vec[5] << endl;
                }
                continue;
            }
            cout << "YES" << endl;
            ll a = vec[0], b = 1, c = vec[vec.size()-1]*vec[vec.size()-2];
            for(ll i = 1; i < vec.size()-2; i++)
            {
                b*=vec[i];
            }
            cout << a << " " << b << " " << c << endl;
        }
    }
}


#include<iostream>
#include<vector>
#include<math.h>
#include<stack>
#include<string>
#include<set>
#include<iomanip>
#include<algorithm>
#include<map>
#include<climits>
#define lld long long
#define constant 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

vector<int> primeFactors(int n)  {
    vector<int> a;
    while (n % 2 == 0)
    {
        a.push_back(2);
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            a.push_back(i);
            n = n/i;
        }
    }

    if (n > 2)
      a.push_back(n);
    return a;
}
int main(){
  int t;
  cin>>t;
  while(t--){
    int n,flag=0;
    cin>>n;
    for(int i=2;i<=min(n,10000);i++){
      for(int j=i+1;j<=min(n,10000);j++){
          int num=n/(i*j);
          if(num!=i && num!=j && (num*i*j)==n && num>=2){
            cout<<"YES"<<endl;
            cout<<i<<" "<<j<<" "<<num<<endl;
            flag=1;
            break;
          }
      }
      if(flag==1)
        break;
    }
    if(flag==0)
      cout<<"NO"<<endl;
    // vector<int> a;
    // map<int,int> m;
    // a=primeFactors(n);
    // for(auto it=a.begin();it!=a.end();it++)
    //   m[it]++;
    // if(m.size()>2){
    //   auto it=m.begin();
    //   cout<<"YES"<<endl;
    //   int num=it->first;
    //   cout<<it->first<<" ";
    //   it++;
    //   num*=it->first;
    //   cout<<it->first<<" ";
    //   cout<<n/num<<endl;
    // }
    // else if(m.size()==1){
    //   if(m.begin()->second>=6){
    //     cout<<"YES"<<endl;
    //   }
    // }

  }

}


#include<iostream>
#include<vector>
#include<math.h>
#include<stack>
#include<string>
#include<set>
#include<iomanip>
#include<algorithm>
#include<map>
#include<climits>
#define lld long long
#define constant 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

vector<int> primeFactors(int n)  {
    vector<int> a;
    while (n % 2 == 0)
    {
        a.push_back(2);
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            a.push_back(i);
            n = n/i;
        }
    }

    if (n > 2)
      a.push_back(n);
    return a;
}
int main(){
  int t;
  cin>>t;
  while(t--){
    int n,flag=0;
    cin>>n;
    for(int i=2;i<=min(n,1000);i++){
      for(int j=2;j<=min(n,1000);j++){
        if(i!=j){
          int num=n/(i*j);
          if(num!=i && num!=j && (num*i*j)==n && num>=2){
            cout<<"YES"<<endl;
            cout<<i<<" "<<j<<" "<<num<<endl;
            flag=1;
            break;
          }
        }
      }
      if(flag==1)
        break;
    }
    if(flag==0)
      cout<<"NO"<<endl;
    // vector<int> a;
    // map<int,int> m;
    // a=primeFactors(n);
    // for(auto it=a.begin();it!=a.end();it++)
    //   m[it]++;
    // if(m.size()>2){
    //   auto it=m.begin();
    //   cout<<"YES"<<endl;
    //   int num=it->first;
    //   cout<<it->first<<" ";
    //   it++;
    //   num*=it->first;
    //   cout<<it->first<<" ";
    //   cout<<n/num<<endl;
    // }
    // else if(m.size()==1){
    //   if(m.begin()->second>=6){
    //     cout<<"YES"<<endl;
    //   }
    // }

  }

}


#include<iostream>
#include<vector>
#include<math.h>
#include<stack>
#include<string>
#include<set>
#include<iomanip>
#include<algorithm>
#include<map>
#include<climits>
#define lld long long
#define constant 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

vector<int> primeFactors(int n)  {
    vector<int> a;
    while (n % 2 == 0)
    {
        a.push_back(2);
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            a.push_back(i);
            n = n/i;
        }
    }

    if (n > 2)
      a.push_back(n);
    return a;
}
int main(){
  int t;
  cin>>t;
  while(t--){
    int n,flag=0;
    cin>>n;
    vector<int> a;
    map<int,int> m;
    a=primeFactors(n);
    for(auto it=a.begin();it!=a.end();it++)
      m[*it]++;
    if(m.size()>2){
      auto it=m.begin();
      cout<<"YES"<<endl;
      int num=it->first;
      cout<<it->first<<" ";
      it++;
      num*=it->first;
      cout<<it->first<<" ";
      cout<<n/num<<endl;
    }
    else if(m.size()==1){
      if(m.begin()->second>=6){
        int num=pow(m.begin()->first,3);
        cout<<"YES"<<endl;
        cout<<m.begin()->first<<" ";
        cout<<m.begin()->first * m.begin()->first<<" ";
        cout<<n/num<<endl;
      }
      else
        cout<<"NO"<<endl;
    }
    else if(m.size()==2){
      auto it=m.begin();
      it++;
      int c=m.begin()->second+it->second;
      if(c>=4){
        cout<<"YES"<<endl;
        cout<<it->first<<" ";
        cout<<m.begin()->first<<" ";
        int num=it->first*m.begin()->first;
        cout<<n/num<<endl;
      }
      else
        cout<<"NO"<<endl;
    }
    else
      cout<<"NO"<<endl;

  }

}


#include<iostream>
#include<vector>
#include<math.h>
#include<stack>
#include<string>
#include<set>
#include<iomanip>
#include<algorithm>
#include<map>
#include<climits>
#define lld long long
#define constant 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

vector<int> primeFactors(int n)  {
    vector<int> a;
    while (n % 2 == 0)
    {
        a.push_back(2);
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            a.push_back(i);
            n = n/i;
        }
    }

    if (n > 2)
      a.push_back(n);
    return a;
}
int main(){
  int t;
  cin>>t;
  while(t--){
    int n;
    cin>>n;
    vector<int> a;
    a=primeFactors(n);
    map<int,int> m;
    for(auto it : a){
      m[it]++;
    }
    if(m.size()>=3){
      cout<<"YES"<<endl;
      auto it=m.begin();
      cout<<pow(it->first,it->second)<<" ";
      it++;
      cout<<pow(it->first,it->second)<<" ";
      it++;
      int num=pow(it->first,it->second);
      while(it!=m.end()){
        it++;
        if(it!=m.end())
          num*=pow(it->first,it->second);
      }
      cout<<num<<" ";
      cout<<endl;
    }
    else if(m.size()==1){
      if(m.begin()->second >= 6){
        cout<<"YES"<<endl;
        cout<<m.begin()->first<<" ";
        cout<<m.begin()->first*2<<" ";
        cout<<pow(m.begin()->first,(m.begin()->second-3))<<" ";
        cout<<endl;
      }
      else{
        cout<<"NO"<<endl;
      }
    }
    else if(m.size()==2){
      int c=m.begin()->second;
      auto it=m.begin();
      it++;
      c+=it->second;
      if(c>=4){
        cout<<"YES"<<endl;
        cout<<m.begin()->first<<" ";
        cout<<it->first<<" ";
        it->second--;
        m.begin()->second--;
        if(it->second>0 && m.begin()->second>0)
          cout<<pow(it->first,it->second)*pow(m.begin()->first,m.begin()->second)<<endl;
        else if(it->second>0 )
          cout<<pow(it->second,it->first)<<endl;
        else if(m.begin()->second>0)
          cout<<pow(m.begin()->first,m.begin()->second)<<endl;
      }
      else
        cout<<"NO"<<endl;

    }

  }

}


#include<iostream>
#include<vector>
#include<math.h>
#include<stack>
#include<string>
#include<set>
#include<iomanip>
#include<algorithm>
#include<map>
#include<climits>
#define lld long long
#define constant 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

vector<int> primeFactors(int n)  {
    vector<int> a;
    while (n % 2 == 0)
    {
        a.push_back(2);
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            a.push_back(i);
            n = n/i;
        }
    }

    if (n > 2)
      a.push_back(n);
    return a;
}
int main(){
  int t;
  cin>>t;
  while(t--){
    int n,flag=0;
    cin>>n;
    for(int i=2;i<=1000;i++){
      for(int j=i+1;j<=1000;j++){
          int num=n/(i*j);
          if(num!=i && num!=j && (num*i*j)==n && num>=2){
            cout<<"YES"<<endl;
            cout<<i<<" "<<j<<" "<<num<<endl;
            flag=1;
            break;
          }
      }
      if(flag==1)
        break;
    }
    if(flag==0)
      cout<<"NO"<<endl;
    // vector<int> a;
    // map<int,int> m;
    // a=primeFactors(n);
    // for(auto it=a.begin();it!=a.end();it++)
    //   m[it]++;
    // if(m.size()>2){
    //   auto it=m.begin();
    //   cout<<"YES"<<endl;
    //   int num=it->first;
    //   cout<<it->first<<" ";
    //   it++;
    //   num*=it->first;
    //   cout<<it->first<<" ";
    //   cout<<n/num<<endl;
    // }
    // else if(m.size()==1){
    //   if(m.begin()->second>=6){
    //     cout<<"YES"<<endl;
    //   }
    // }

  }

}


#include<iostream>
#include<vector>
#include<math.h>
#include<stack>
#include<string>
#include<set>
#include<iomanip>
#include<algorithm>
#include<map>
#include<climits>
#define lld long long
#define constant 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

vector<int> primeFactors(int n)  {
    vector<int> a;
    while (n % 2 == 0)
    {
        a.push_back(2);
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            a.push_back(i);
            n = n/i;
        }
    }

    if (n > 2)
      a.push_back(n);
    return a;
}
int main(){
  int t;
  cin>>t;
  while(t--){
    int n,flag=0;
    cin>>n;
    for(int i=2;i<min(n,1000);i++){
      for(int j=2;j<min(n,1000);j++){
        if(i!=j){
          int num=n/(i*j);
          if(num!=i && num!=j && num*i*j==n && num>=2){
            cout<<"YES"<<endl;
            cout<<i<<" "<<j<<" "<<num<<endl;
            flag=1;
            break;
          }
        }
      }
      if(flag==1)
        break;
    }
    if(flag==0)
      cout<<"NO"<<endl;
    // vector<int> a;
    // map<int,int> m;
    // a=primeFactors(n);
    // for(auto it=a.begin();it!=a.end();it++)
    //   m[it]++;
    // if(m.size()>2){
    //   auto it=m.begin();
    //   cout<<"YES"<<endl;
    //   int num=it->first;
    //   cout<<it->first<<" ";
    //   it++;
    //   num*=it->first;
    //   cout<<it->first<<" ";
    //   cout<<n/num<<endl;
    // }
    // else if(m.size()==1){
    //   if(m.begin()->second>=6){
    //     cout<<"YES"<<endl;
    //   }
    // }

  }

}


#include<iostream>
#include<vector>
#include<math.h>
#include<stack>
#include<string>
#include<set>
#include<iomanip>
#include<algorithm>
#include<map>
#include<climits>
#define lld long long
#define constant 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

// vector<int> primeFactors(int n)  {
//     vector<int> a;
//     while (n % 2 == 0)
//     {
//         a.push_back(2);
//         n = n/2;
//     }
//
//     for (int i = 3; i <= sqrt(n); i = i + 2)
//     {
//         while (n % i == 0)
//         {
//             a.push_back(i);
//             n = n/i;
//         }
//     }
//
//     if (n > 2)
//       a.push_back(n);
//     return a;
// }
int main(){
  int t;
  cin>>t;
  while(t--){
    int n,flag=0;
    cin>>n;
    for(int i=2;i<min(n,1000);i++){
      for(int j=2;j<min(n,1000);j++){
        for(int k=2;k<min(n,1000);k++){
          if(i!=j && i!=k && j!=k && i*j*k==n){
            cout<<"YES"<<endl;
            cout<<i<<" "<<j<<" "<<k<<endl;
            flag=1;
            break;
          }
        }
        if(flag==1)
          break;
      }
      if(flag==1)
        break;
    }
    if(flag==0)
      cout<<"NO"<<endl;
  }

}


#include<iostream>
#include<vector>
#include<math.h>
#include<stack>
#include<string>
#include<set>
#include<iomanip>
#include<algorithm>
#include<map>
#include<climits>
#define lld long long
#define constant 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

vector<int> primeFactors(int n)  {
    vector<int> a;
    while (n % 2 == 0)
    {
        a.push_back(2);
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            a.push_back(i);
            n = n/i;
        }
    }

    if (n > 2)
      a.push_back(n);
    return a;
}
int main(){
  int t;
  cin>>t;
  while(t--){
    int n;
    cin>>n;
    vector<int> a;
    a=primeFactors(n);
    map<int,int> m;
    for(auto it : a){
      m[it]++;
    }
    if(m.size()>=3){
      cout<<"YES"<<endl;
      auto it=m.begin();
      cout<<pow(it->first,it->second)<<" ";
      int x=pow(it->first,it->second),y;
      it++;
      cout<<pow(it->first,it->second)<<" ";
      y=pow(it->first,it->second);
      int num;
      cout<<n/(x*y);
      cout<<endl;
    }
    else if(m.size()==1){
      if(m.begin()->second >= 6){
        cout<<"YES"<<endl;
        cout<<m.begin()->first<<" ";
        cout<<pow(m.begin()->first,2)<<" ";
        int num=pow(m.begin()->first,2)*m.begin()->first;
        cout<<n/num<<" ";
        cout<<endl;
      }
      else{
        cout<<"NO"<<endl;
      }
    }
    else if(m.size()==2){
      int c=m.begin()->second;
      auto it=m.begin();
      it++;
      c+=it->second;
      if(c>=4){
        cout<<"YES"<<endl;
        cout<<m.begin()->first<<" ";
        cout<<it->first<<" ";
        it->second--;
        m.begin()->second--;
        if(it->second>0 && m.begin()->second>0)
          cout<<pow(it->first,it->second)*pow(m.begin()->first,m.begin()->second)<<endl;
        else if(it->second>0 )
          cout<<pow(it->second,it->first)<<endl;
        else if(m.begin()->second>0)
          cout<<pow(m.begin()->first,m.begin()->second)<<endl;
      }
      else
        cout<<"NO"<<endl;

    }

  }

}


#include<iostream>
#include<vector>
#include<math.h>
#include<stack>
#include<string>
#include<set>
#include<iomanip>
#include<algorithm>
#include<map>
#include<climits>
#define lld long long
#define constant 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

vector<int> primeFactors(int n)  {
    vector<int> a;
    while (n % 2 == 0)
    {
        a.push_back(2);
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            a.push_back(i);
            n = n/i;
        }
    }

    if (n > 2)
      a.push_back(n);
    return a;
}
int main(){
  int t;
  cin>>t;
  while(t--){
    int n,flag=0;
    cin>>n;
    for(int i=2;i<=10000;i++){
      for(int j=i+1;j<=10000;j++){
          int num=n/(i*j);
          if(num!=i && num!=j && (num*i*j)==n && num>=2){
            cout<<"YES"<<endl;
            cout<<i<<" "<<j<<" "<<num<<endl;
            flag=1;
            break;
          }
      }
      if(flag==1)
        break;
    }
    if(flag==0)
      cout<<"NO"<<endl;
    // vector<int> a;
    // map<int,int> m;
    // a=primeFactors(n);
    // for(auto it=a.begin();it!=a.end();it++)
    //   m[it]++;
    // if(m.size()>2){
    //   auto it=m.begin();
    //   cout<<"YES"<<endl;
    //   int num=it->first;
    //   cout<<it->first<<" ";
    //   it++;
    //   num*=it->first;
    //   cout<<it->first<<" ";
    //   cout<<n/num<<endl;
    // }
    // else if(m.size()==1){
    //   if(m.begin()->second>=6){
    //     cout<<"YES"<<endl;
    //   }
    // }

  }

}


#include<iostream>
#include<vector>
#include<math.h>
#include<stack>
#include<string>
#include<set>
#include<iomanip>
#include<algorithm>
#include<map>
#include<climits>
#define lld long long
#define constant 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

vector<int> primeFactors(int n)  {
    vector<int> a;
    while (n % 2 == 0)
    {
        a.push_back(2);
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            a.push_back(i);
            n = n/i;
        }
    }

    if (n > 2)
      a.push_back(n);
    return a;
}
int main(){
  int t;
  cin>>t;
  while(t--){
    int n,flag=0;
    cin>>n;
    for(int i=2;i<=min(n,1000);i++){
      for(int j=i+1;j<=min(n,1000);j++){
          int num=n/(i*j);
          if(num!=i && num!=j && (num*i*j)==n && num>=2){
            cout<<"YES"<<endl;
            cout<<i<<" "<<j<<" "<<num<<endl;
            flag=1;
            break;
          }
      }
      if(flag==1)
        break;
    }
    if(flag==0)
      cout<<"NO"<<endl;
    // vector<int> a;
    // map<int,int> m;
    // a=primeFactors(n);
    // for(auto it=a.begin();it!=a.end();it++)
    //   m[it]++;
    // if(m.size()>2){
    //   auto it=m.begin();
    //   cout<<"YES"<<endl;
    //   int num=it->first;
    //   cout<<it->first<<" ";
    //   it++;
    //   num*=it->first;
    //   cout<<it->first<<" ";
    //   cout<<n/num<<endl;
    // }
    // else if(m.size()==1){
    //   if(m.begin()->second>=6){
    //     cout<<"YES"<<endl;
    //   }
    // }

  }

}


/**
 *  Submitting by the name of Maa Sarashwati and Maa Bishwakarma.
**/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    int t;
    cin>>t;
    while(t--)
    {
        vector<int>v;
        cin>>n;
        int k,j,l;
        bool flag=0;
        for(int i=2;i<n;i++)
        {
            if(n%i==0){ v.push_back(i); break;}
        }
        for(int i=v[0]+1;i<n;i++)
        {
            if(n%(v[0]*i)==0 && n/(v[0]*i)!=v[0] && n/(v[0]*i)!=i && n/(v[0]*i)*v[0]*i==n && n/(v[0]*i)!=1 )
            {
                flag=1;
                k=v[0];
                j=i;
                l=n/(v[0]*i);
                break;
            }
        }
        cout<<v[0]<<endl;
        if(flag) cout<<"YES\n"<<k<<' '<<j<<' '<<l<<endl;
        else cout<<"NO"<<endl;
    }

}


/**
 *  Submitting by the name of Maa Sarashwati and Maa Bishwakarma.
**/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    int t;
    cin>>t;
    while(t--)
    {
        vector<int>v;
        int co=0;
        cin>>n;
        for(int i=2;i<=sqrt(n)+1;i++)
        {
            if(co==2) break;
            else{
            if(n%i==0) {v.push_back(i); co+=1;}
            }
        }
    if(v.size()==2){
        if((n%(v[0]*v[1])==0 && n/(v[0]*v[1])*v[0]*v[1]==n))
    {

        cout<<"YES"<<endl;
        cout<<v[0]<<' '<<v[1]<<' '<<n/(v[0]*v[1])<<endl;
    }
        else cout<<"NO"<<endl;
     //   cout<<co<<endl;
       // cout<<v[0]<<' '<<v[1]<<' '<<n/(v[0]*v[1])<<endl\;
            }
            else cout<<"NO"<<endl;
    }

}


/**
 *  Submitting by the name of Maa Sarashwati and Maa Bishwakarma.
**/
#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long n;
    int t;
    cin>>t;
    while(t--)
    {
        vector<int>v;
        cin>>n;
        int k,j,l;
        bool flag=0;
        if(n==2 || n==3 || n==5 || n==7 || n==11 ||n==13|| n==17 || n==19 ||n==23 || n==29) cout<<"NO"<<endl;
        else{
        for(int i=2;i<=sqrt(n)+1;i++)
        {
            if(n%i==0){ v.push_back(i); break;}
        }
        if(v.size()==0) cout<<"NO"<<endl;
        else{
        for(int i=2;i<=sqrt(n)+1;i++)
        {

            if(n%(v[0]*i)==0 && n/(v[0]*i)!=v[0] && n/(v[0]*i)!=i && n/(v[0]*i)*v[0]*i==n && n/(v[0]*i)!=1 && i!=v[0])
            {
                flag=1;
                k=v[0];
                j=i;
                l=n/(v[0]*i);
                break;
            }
        }
       // cout<<v[0]<<endl;
        if(flag) cout<<"YES\n"<<k<<' '<<j<<' '<<l<<endl;
        else cout<<"NO"<<endl;
    }
    }
    }

}


/**
 *  Submitting by the name of Maa Sarashwati and Maa Bishwakarma.
**/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    int t;
    cin>>t;
    while(t--)
    {
        vector<int>v;
        cin>>n;
        int k,j,l;
        bool flag=0;
        for(int i=2;i<=sqrt(n)+1;i++)
        {
            if(n%i==0){ v.push_back(i); break;}
        }
        for(int i=2;i<=sqrt(n)+1;i++)
        {

            if(n%(v[0]*i)==0 && n/(v[0]*i)!=v[0] && n/(v[0]*i)!=i && n/(v[0]*i)*v[0]*i==n && n/(v[0]*i)!=1 && i!=v[0])
            {
                flag=1;
                k=v[0];
                j=i;
                l=n/(v[0]*i);
                break;
            }
        }
       // cout<<v[0]<<endl;
        if(flag) cout<<"YES\n"<<k<<' '<<j<<' '<<l<<endl;
        else cout<<"NO"<<endl;
    }

}


/**
 *  Submitting by the name of Maa Sarashwati and Maa Bishwakarma.
**/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    int t;
    cin>>t;
    while(t--)
    {
        vector<int>v;
        cin>>n;
        int k,j,l;
        bool flag=0;
        for(int i=2;i<n;i++)
        {
            if(n%i==0){ v.push_back(i); break;}
        }
        for(int i=v[0]+1;i<n;i++)
        {
            if(n%(v[0]*i)==0 && n/(v[0]*i)!=v[0] && n/(v[0]*i)!=i && n/(v[0]*i)*v[0]*i==n && n/(v[0]*i)!=1 )
            {
                flag=1;
                k=v[0];
                j=i;
                l=n/(v[0]*i);
                break;
            }
        }
       // cout<<v[0]<<endl;
        if(flag) cout<<"YES\n"<<k<<' '<<j<<' '<<l<<endl;
        else cout<<"NO"<<endl;
    }

}


/**
 *  Submitting by the name of Maa Sarashwati and Maa Bishwakarma.
**/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    int t;
    cin>>t;
    while(t--)
    {
        vector<int>v;
        cin>>n;
        int k,j,l;
        bool flag=0;
        for(int i=2;i<=n;i++)
        {
            if(n%i==0){ v.push_back(i); break;}
        }
        for(int i=2;i<=n;i++)
        {
            if(n%(v[0]*i)==0 && n/(v[0]*i)!=v[0] && n/(v[0]*i)!=i && n/(v[0]*i)*v[0]*i==n && n/(v[0]*i)!=1 && i!=v[0])
            {
                flag=1;
                k=v[0];
                j=i;
                l=n/(v[0]*i);
                break;
            }
        }
       // cout<<v[0]<<endl;
        if(flag) cout<<"YES\n"<<k<<' '<<j<<' '<<l<<endl;
        else cout<<"NO"<<endl;
    }

}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll t;

    cin >> t;

    while(t--){
        ll n;

        cin >> n;

        vector<ll> ans;

        ll d = 2;

        while(d*d*d <= n){
            ll dd = 1, k = 0;
            while(n % d == 0){
                n /= d;

                dd *= d;
                k++;
            }

            if(dd != 1){
                ans.push_back(dd);
            }

            if(k >= 6 && ans.size() == 1){
                cout << "YES\n" << d << ' ' << d * d << ' ' << n * dd / d / d / d << "\n";
                break;
            }

            d++;

            if(ans.size() == 2){
                cout << "YES\n" << ans[0] << ' ' << ans[1] << ' ' << n << "\n";
                break;
            }
        }

        cout << "NO\n";
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll t;

    cin >> t;

    while(t--){
        ll n;

        cin >> n;

        vector<ll> ans;

        ll d = 2, k = 0;

        while(d*d*d <= n){
            ll f = 0;

            while(n % d == 0){
                n /= d;

                ans.push_back(d);
                if(f == 0){
                    f = 1;
                    k++;
                }
            }
            d++;
        }
        // cout << n << ' ' << k << endl;
        if(n > 1){
            ans.push_back(n);
            k++;
        }
        sort(ans.begin(), ans.end());
        //cout << k << ' ' << ans.size() << endl;
        //cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl;
        if(k >= 3){
            ll a = ans[0], i = 1;
            while(ans[i] == a){
                a *= ans[0];
                i++;
            }
            ll b = ans[i], j = i;
            i++;
            while(ans[i] == b){
                b *= ans[j];
                i++;
            }
            ll c = ans[i];
            j = i;
            i++;
            while(i < ans.size() && ans[i] == c){
                c *= ans[j];
                i++;
            }
            cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
        }
        if(k == 2){
            if(ans.size() > 2){
                ll a = ans[0], c = ans[ans.size() - 1], b = ans[1];
                for(ll i = 2; i<ans.size()-1; i++){
                    b *= ans[i];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
        if(k == 1){
            if(ans.size() >= 6){
                ll a = ans[0], b = ans[0] * ans[0], c = 1;
                for(ll i = 3; i<ans.size(); i++){
                    c *= ans[0];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll t;

    cin >> t;

    while(t--){
        ll n;

        cin >> n;

        vector<ll> ans;

        ll d = 2, k = 0, N = n;
        ll w = ceil(pow(N, 1./2));

        while(d <= w + 1){
            ll f = 0;

            while(n % d == 0){
                n /= d;

                ans.push_back(d);
                if(f == 0){
                    f = 1;
                    k++;
                }
            }
            d++;
        }
        //cout << n << ' ' << k << endl;
        if(n > 1){
            ans.push_back(n);
            k++;
        }
        sort(ans.begin(), ans.end());
        //cout << k << ' ' << ans.size() << endl;
        //cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl;

        if(k >= 2){
            if(ans.size() > 3){
                ll a = ans[0], c = ans[ans.size() - 1], b = ans[1];
                for(ll i = 2; i<ans.size()-1; i++){
                    b *= ans[i];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
        if(k == 1){
            if(ans.size() >= 6){
                ll a = ans[0], b = ans[0] * ans[0], c = 1;
                for(ll i = 3; i<ans.size(); i++){
                    c *= ans[0];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll t;

    cin >> t;

    while(t--){
        ll n;

        cin >> n;

        vector<ll> ans;

        ll d = 2, k = 0;

        while(d*d*d <= n){
            ll f = 0;

            while(n % d == 0){
                n /= d;

                ans.push_back(d);
                if(f == 0){
                    f = 1;
                    k++;
                }
            }
            d++;
        }
        // cout << n << ' ' << k << endl;
        if(n > 1){
            ans.push_back(n);
            k++;
        }
        sort(ans.begin(), ans.end());
        //cout << k << ' ' << ans.size() << endl;
        //cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl;
        if(k >= 3){
            ll a = ans[0], i = 1;
            while(ans[i] == a){
                a *= ans[0];
                i++;
            }
            ll b = ans[i], j = i;
            i++;
            while(ans[i] == b){
                b *= ans[j];
                i++;
            }
            ll c = ans[i];
            j = i;
            i++;
            while(i < ans.size() && ans[i] == c){
                c *= ans[j];
                i++;
            }
            cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
        }
        if(k == 2){
            if(ans.size() > 3){
                ll a = ans[0], c = ans[ans.size() - 1], b = ans[1];
                for(ll i = 2; i<ans.size()-1; i++){
                    b *= ans[i];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
        if(k == 1){
            if(ans.size() >= 6){
                ll a = ans[0], b = ans[0] * ans[0], c = 1;
                for(ll i = 3; i<ans.size(); i++){
                    c *= ans[0];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll t;

    cin >> t;

    while(t--){
        ll n;

        cin >> n;

        vector<ll> ans;

        ll d = 2, k = 0, N = n;

        while(d*d*d <= N){
            ll f = 0;

            while(n % d == 0){
                n /= d;

                ans.push_back(d);
                if(f == 0){
                    f = 1;
                    k++;
                }
            }
            d++;
        }
        // cout << n << ' ' << k << endl;
        if(n > 1){
            ans.push_back(n);
            k++;
        }
        sort(ans.begin(), ans.end());
        //cout << k << ' ' << ans.size() << endl;
        //cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl;
        if(k >= 3){
            ll a = ans[0], i = 1;
            while(ans[i] == a){
                a *= ans[0];
                i++;
            }
            ll b = ans[i], j = i;
            i++;
            while(ans[i] == b){
                b *= ans[j];
                i++;
            }
            ll c = ans[i];
            j = i;
            i++;
            while(i < ans.size()){
                c *= ans[j];
                i++;
            }
            cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
        }
        if(k == 2){
            if(ans.size() > 3){
                ll a = ans[0], c = ans[ans.size() - 1], b = ans[1];
                for(ll i = 2; i<ans.size()-1; i++){
                    b *= ans[i];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
        if(k == 1){
            if(ans.size() >= 6){
                ll a = ans[0], b = ans[0] * ans[0], c = 1;
                for(ll i = 3; i<ans.size(); i++){
                    c *= ans[0];
                }
                cout << "YES\n" << a << ' ' << b << ' ' << c << "\n";
            }
            else{
                cout << "NO\n";
            }
        }
    }
}