#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n, f = 0;
    cin >> n;
    long long i = 2;
    while (i * i < n) {
      if (n % i == 0) {
        f = 1;
        break;
      }
      i++;
    }
    n = n / i;
    if (n > i && f) {
      f = 0;
      long long j = i + 1;
      while (j * j < n) {
        if (n % j == 0) {
          f = 1;
          break;
        }
        j++;
      }
      n /= j;
      if (f && n > j) cout << "YES\n" << i << " " << j << " " << n << "\n";
    }
    if (f == 0) cout << "NO\n";
  }
  return 0;
}
