#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, cp = 0;
    cin >> n;
    vector<long long int> v1;
    long long int i;
    for (i = 2; i <= sqrt(n); i++) {
      if (n % i == 0 && n / i != i) {
        v1.push_back(i);
        cp++;
        n /= i;
        break;
      }
    }
    if (!cp)
      cout << "NO" << endl;
    else {
      for (long long int j = sqrt(n); j > i; j--) {
        if (n % j == 0 && n / j != j) {
          v1.push_back(j);
          v1.push_back(n / j);
          break;
        }
      }
      if (v1.size() == 3) {
        cout << "YES" << endl;
        cout << v1[0] << " " << v1[1] << " " << v1[2] << endl;
      } else
        cout << "NO" << endl;
    }
  }
  return 0;
}
