#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> arr;
vector<pair<long long, long long>> arr2;
vector<long long> dels;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long q;
  cin >> q;
  while (q--) {
    long long n;
    cin >> n;
    long long v = -1;
    for (long long i = 2; i * i < n; i++) {
      if (n % i == 0) {
        for (long long j = 2; j * j <= i; j++) {
          if (i % j == 0 && i / j != 1 && i / j != n / i && n / i != j &&
              j != i / j) {
            cout << "YES\n" << i / j << ' ' << n / i << ' ' << j << endl;
            goto r;
          }
        }
        for (long long j = 2; j * j <= n / i; j++) {
          if ((n / i) % j == 0 && (n / i) / j != 1 && (n / i) / j != i &&
              i != j && j != (n / i) / j) {
            cout << "YES\n" << (n / i) / j << ' ' << i << ' ' << j << endl;
            goto r;
          }
        }
      }
    }
    cout << "NO\n";
  r:;
  }
  return 0;
}
