#include <bits/stdc++.h>
using namespace std;
using namespace std;
void solve() {
  int n;
  cin >> n;
  int arr[3];
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      arr[0] = i;
      n /= i;
      break;
    }
  }
  bool good1 = false;
  for (int j = 2; j <= sqrt(n); j++) {
    if (n % j == 0) {
      if (j != n && j != arr[0]) {
        arr[1] = j;
        n /= j;
        good1 = true;
        break;
      }
    }
  }
  if (n != arr[0] && n != arr[1] && n != 1 && good1)
    cout << "YES\n" << arr[0] << " " << arr[1] << " " << n << "\n";
  else
    cout << "NO\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
