#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t;
  cin >> t;
  while (t > 0) {
    long long int n;
    cin >> n;
    long long int a[3] = {0};
    long long int count = 0;
    for (long long int i = 2; i < sqrt(n); i++) {
      if (n % i == 0) {
        if (count == 1) {
          a[1] = i;
          a[2] = n / i;
          break;
        }
        count++;
        n /= i;
        a[0] = i;
      }
    }
    if (a[0] == a[1] || a[1] == a[2] || a[2] == a[0]) {
      cout << "NO"
           << "\n";
    } else {
      cout << "YES"
           << "\n";
      cout << a[0] << " " << a[1] << " " << a[2] << "\n";
    }
    t--;
  }
}
