#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using edge = tuple<int, int, int, int>;
using graph = vector<vector<edge>>;
void go() {
  ll n;
  cin >> n;
  ll a, b, c, m;
  for (a = 2; a * a <= n; a++) {
    if (n % a == 0) {
      m = n / a;
      for (b = 2; b * b <= m; b++) {
        if (m % b == 0) {
          c = m / b;
          if (a != b && a != c && b != c) {
            cout << "YES\n";
            if (a < b && a < c)
              cout << a << " " << min(b, c) << " " << max(b, c) << "\n";
            else if (b < a && b < c)
              cout << b << " " << min(a, c) << " " << max(a, c) << "\n";
            else
              cout << c << " " << min(a, b) << " " << max(a, b) << "\n";
            return;
          }
        }
      }
    }
  }
  cout << "NO\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) go();
}
