#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int add(int a, int b) {
  long long x = a + b;
  if (x >= 1000000007) x -= 1000000007;
  if (x < 0) x += 1000000007;
  return x;
}
long long mul(long long a, long long b) { return (a * b) % 1000000007; }
long long pw(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed() {
  long long a = rng();
  return a;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  for (; t; --t) {
    int n;
    cin >> n;
    int aa = 0, bb = 0, cc = 0;
    for (int i = 2; i * i <= n; ++i)
      if (n % i == 0) {
        aa = i;
        n /= i;
        break;
      }
    for (int i = 2; i * i <= n; ++i)
      if (n % i == 0 && i != aa) {
        bb = i;
        n /= i;
        break;
      }
    cc = n;
    if (aa && bb && cc && aa != bb && aa != cc && bb != cc) {
      cout << "YES\n";
      cout << aa << " " << bb << " " << cc << '\n';
    } else
      cout << "NO\n";
  }
  return 0;
}
