#include <bits/stdc++.h>
using Int = long long;
using namespace std;
vector<pair<Int, Int>> primeFactors(Int n) {
  vector<pair<Int, Int>> result;
  Int factor = 0;
  Int factorCount = 0;
  Int q = n;
  if (n >= 2) {
    for (Int i = 2; i * i <= n;) {
      if (q % i == 0) {
        if (i != factor) {
          factor = i;
          factorCount = 1;
        } else {
          factorCount++;
        }
        q /= i;
      } else {
        if (factor > 0) {
          result.push_back(make_pair(factor, factorCount));
          factor = 0;
        }
        i++;
      }
    }
  }
  if (q > 1) {
    result.push_back(make_pair(q, 1));
  }
  return result;
}
int main() {
  int t;
  cin >> t;
  for (int i = 0, i_len = (int)(t); i < i_len; i++) {
    Int n;
    cin >> n;
    auto factors = primeFactors(n);
    if (((int)(factors).size()) == 1) {
      auto p = factors[0].first;
      auto e = factors[0].second;
      if (e >= 6) {
        puts("YES");
        printf("%lld %lld %lld \n", p, p * p, n / (p * p * p));
      } else {
        puts("NO");
      }
    } else if (((int)(factors).size()) == 2) {
      auto p0 = factors[0].first;
      auto e0 = factors[0].second;
      auto p1 = factors[1].first;
      auto e1 = factors[1].second;
      if (e0 + e1 <= 3) {
        puts("NO");
      } else {
        puts("YES");
        printf("%lld %lld %lld \n", p0, p1, n / (p0 * p1));
      }
    } else {
      auto p = factors[0].first;
      auto q = factors[1].first;
      puts("YES");
      printf("%lld %lld %lld \n", p, q, n / (p * q));
    }
  }
}
