#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, i, cnt = 0, d, ar[3];
  cin >> n;
  for (i = 2; i * i <= n; i++)
    if (n % i == 0) {
      ar[cnt++] = i;
      n /= i;
      if (cnt == 2) break;
    }
  if (cnt == 2) {
    ar[2] = n;
    sort(ar, ar + 3);
    if (ar[0] != ar[1] && ar[1] != ar[2]) {
      cout << "YES\n" << ar[0] << ' ' << ar[1] << ' ' << ar[2] << '\n';
      return;
    }
  }
  cout << "NO\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) solve();
  return 0;
}
