#include <bits/stdc++.h>
#pragma 03
using namespace std;
vector<pair<long long, long long> > pfac;
long long binpow(long long x, long long y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  long long res = binpow(x, y / 2);
  if (y % 2 == 0)
    return res * res;
  else
    return res * res * x;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  long long n, x, num;
  while (t--) {
    cin >> n;
    pfac.clear();
    if (n < 24) {
      cout << "NO\n";
      continue;
    }
    x = n;
    for (long long i = 2; i < sqrt(n); i++) {
      if (x % i == 0) {
        num = 0;
        while (x % i == 0) {
          num++;
          x /= i;
        }
        pfac.push_back(pair<long long, long long>(i, num));
      }
      if (x == 1) break;
    }
    if (x != 1) pfac.push_back(pair<long long, long long>(x, 1));
    if (pfac.empty()) {
      cout << "NO\n";
      continue;
    } else if (pfac.size() == 1) {
      if (pfac[0].second >= 6) {
        cout << "YES\n";
        cout << pfac[0].first << " " << pfac[0].first * pfac[0].first << " "
             << binpow(pfac[0].first, pfac[0].second - 3) << "\n";
      } else {
        cout << "NO\n";
      }
    } else if (pfac.size() == 2) {
      if (pfac[0].second <= 2 && pfac[1].second <= 2) {
        if (pfac[0].second < 2 or pfac[1].second < 2) {
          cout << "NO\n";
        } else {
          cout << "YES\n";
          cout << pfac[0].first << " " << pfac[1].first << " "
               << pfac[0].first * pfac[1].first << "\n";
        }
      } else {
        cout << "YES\n";
        cout << pfac[0].first << " " << pfac[1].first << " "
             << binpow(pfac[0].first, pfac[0].second - 1) *
                    binpow(pfac[1].first, pfac[1].second - 1)
             << "\n";
      }
    } else {
      long long neu = 1;
      for (long long i = 2; i < pfac.size(); i++) {
        neu *= binpow(pfac[i].first, pfac[i].second);
      }
      cout << "YES\n";
      cout << binpow(pfac[0].first, pfac[0].second) << " "
           << binpow(pfac[1].first, pfac[1].second) << " " << neu << "\n";
    }
  }
}
