#include <bits/stdc++.h>
using namespace std;
void solve() {
  set<int> s;
  int n, i, a, l, p = 1, pr = 1;
  cin >> n;
  l = n;
  for (i = 2; i * i <= l; i++) {
    if (n % i == 0 && p < 3) {
      s.insert(i);
      n = n / i;
      if (p == 2 && n != 1) {
        s.insert(n);
      }
      p++;
    }
  }
  for (set<int>::iterator i = s.begin(); i != s.end(); i++) {
    pr = pr * (*i);
  }
  if (s.size() > 2 && pr == l) {
    cout << "YES\n";
    for (set<int>::iterator i = s.begin(); i != s.end(); i++) cout << *i << " ";
    cout << "\n";
  } else
    cout << "NO\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
