#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int a[N];
void solve() {
  int n;
  cin >> n;
  set<int> s;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0 && s.find(i) == s.end()) {
      n /= i;
      s.insert(i);
      break;
    }
  }
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0 && s.find(i) == s.end()) {
      n /= i;
      s.insert(i);
      break;
    }
  }
  if ((int)s.size() < 2 || n == 1 || s.find(n) != s.end())
    cout << "NO\n";
  else {
    cout << "YES\n";
    s.insert(n);
    for (auto it : s) cout << it << " ";
    cout << "\n";
  }
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
