#include <bits/stdc++.h>
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, 1, -1, 0, 0, -1, 1};
const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9 + 7;
const int maxn = (int)2e5 + 5;
const int LOGN = 20;
bitset<10000005> isprime;
vector<long long> prime;
vector<long long> ans;
void sieve() {
  isprime[0] = isprime[1] = 1;
  prime.push_back(2);
  for (long long i = 3; i * i <= 10000005; i += 2) {
    if (!isprime[i]) {
      for (long long j = i * i; j <= 10000005; j += i + i) {
        isprime[j] = 1;
      }
    }
  }
  for (long long i = 3; i <= 10000005; i += 2) {
    if (!isprime[i]) {
      prime.push_back(i);
    }
  }
}
int main() {
  long long a, b, cnt, n, s, t;
  cin >> t;
  sieve();
  while (t--) {
    int f = 0;
    cin >> n;
    b = n;
    for (int i = 0; prime[i] * prime[i] <= n && i < prime.size(); i++) {
      if (n % prime[i] == 0) {
        while (n % prime[i] == 0) {
          n /= prime[i];
          ans.push_back(prime[i]);
        }
      }
    }
    if (n != 1) ans.push_back(n);
    int x = ans[0], y = 1, z = 1, j;
    for (int i = 1; i < ans.size(); i++) {
      y *= ans[i];
      if (y == x)
        continue;
      else {
        j = i;
        break;
      }
    }
    for (j++; j < ans.size(); j++) {
      z *= ans[j];
    }
    if (x != 1 && y != 1 && z != 1 && x != y && x != z && y != z) {
      cout << "YES" << endl;
      cout << x << " " << y << " " << z << endl;
    } else
      cout << "NO" << endl;
    ans.clear();
  }
  return 0;
}
