#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> p;
void solve() {
  cin >> n;
  p.clear();
  int cur = n;
  for (int i = 2; i * i <= cur; i++) {
    while (cur % i == 0) {
      p.push_back(i);
      cur /= i;
    }
  }
  if (cur > 1) {
    p.push_back(cur);
  }
  sort(p.begin(), p.end());
  if ((int)p.size() < 3) {
    puts("NO");
    return;
  }
  if (p[0] != p.back()) {
    int num = 1;
    for (int i = 1; i < (int)p.size() - 1; i++) {
      num *= p[i];
    }
    if (p[0] != p.back() && p[0] != num && p.back() != num) {
      puts("YES");
      cout << p[0] << " " << p.back() << " " << num << endl;
    } else {
      puts("NO");
    }
  } else {
    if ((int)p.size() - 3 <= 2) {
      puts("NO");
      return;
    }
    int num = 1;
    for (int i = 3; i < (int)p.size(); i++) {
      num *= p[i];
    }
    if (p[0] != p[0] * p[0] && p[0] != num && p[0] * p[0] != num) {
      puts("YES");
      cout << p[0] << " " << p[0] * p[0] << " " << num << endl;
    } else {
      puts("NO");
    }
  }
}
int main() {
  int tn;
  cin >> tn;
  while (tn--) {
    solve();
  }
  return 0;
}
