#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, k = 0;
  cin >> t;
  while (t > 0) {
    k = 0;
    long long n, a, b, c;
    cin >> n;
    for (long long i = 2; i <= sqrt(n); i++) {
      if (n % i == 0) {
        k = 0;
        for (long long j = 2; j <= sqrt(n / i); j++) {
          if (i != j && (n / (i * j)) != i && (n / (i * j)) != j &&
              (n % (i * j)) == 0) {
            cout << "YES\n";
            cout << i << " " << j << " " << n / (i * j) << endl;
            k++;
            break;
          }
        }
        if (k == 1) break;
      }
    }
    if (k == 0) cout << "NO\n";
    t--;
  }
  return 0;
}
