#include <bits/stdc++.h>
using namespace std;
long long ans[3];
int main() {
  int t;
  cin >> t;
  long long n;
  for (int o = 0; o < t; o++) {
    cin >> n;
    vector<long long> z;
    long long r = sqrt(n) + 1;
    for (long long i = 2; i <= r; i++) {
      {
        while (n % i == 0) {
          n /= i;
          z.push_back(i);
        }
      }
    }
    if (n != 1) {
      z.push_back(n);
    }
    long long prev = 1;
    set<long long> anses;
    for (auto x : z) {
      prev *= x;
      if (anses.size() >= 3) {
        ans[2] *= x;
        continue;
      }
      if (anses.find(prev) == anses.end()) {
        anses.insert(prev);
        ans[anses.size() - 1] = prev;
        prev = 1;
      }
    }
    if (anses.size() >= 3) {
      cout << "YES" << endl;
      cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
    } else {
      cout << "NO" << endl;
    }
    z.clear();
  }
  return 0;
}
