#include <bits/stdc++.h>
using namespace std;
const int ma1 = 3e5 + 5;
string no = "NO", yes = "YES";
const unsigned int MAX1 = 1000000007;
void f(int n) {
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      int d = n / i;
      for (int j = i + 1; j < sqrt(d); j++) {
        if (d % j == 0) {
          cout << yes << endl;
          cout << i << " " << j << " " << d / j << endl;
          return;
        }
      }
    }
  }
  cout << no << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    f(n);
  }
}
