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