#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
const long long N = 2e5;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long t;
  cin >> t;
  ;
  while (t--) {
    long long n;
    cin >> n;
    ;
    long long cpy = n;
    map<long long, long long> mp;
    long long sqr = sqrt(n + 1);
    for (long long i = (2); i <= (sqr); i++) {
      while (n % i == 0) {
        n /= i;
        mp[i]++;
      }
    }
    if (n > 1) mp[n]++;
    if (mp.size() >= 3) {
      cout << "YES\n";
      long long x = (*mp.begin()).first, y = (*(++mp.begin())).first;
      cout << x << " " << y << " " << cpy / (x * y) << '\n';
    } else if (mp.size() == 1) {
      long long x = (*mp.begin()).first, y = (*mp.begin()).second;
      if (y < 6)
        cout << "NO\n";
      else {
        cout << "YES\n";
        cout << x << " " << x * x << " " << cpy / (x * x * x) << '\n';
      }
    } else {
      long long x = (*mp.begin()).first, y = (*(++mp.begin())).first,
                z = cpy / (x * y);
      if (z == x || z == y || z == 1)
        cout << "NO\n";
      else {
        cout << "YES\n";
        cout << x << " " << y << " " << z << '\n';
      }
    }
  }
}
