#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  long long int n, i, j, k;
  vector<long long int> vec;
  cin >> t;
  while (t--) {
    int flag = 0;
    vec.clear();
    cin >> n;
    for (i = 2; i * i <= n; i++) {
      if (n % i == 0) {
        if (i != (n / i)) {
          vec.push_back(i);
          vec.push_back(n / i);
        } else
          vec.push_back(i);
      }
    }
    sort(vec.begin(), vec.end());
    long long int m = vec.size();
    for (i = 0; i < m; i++) {
      for (j = i + 1; j < m; j++) {
        for (k = j + 1; k < m; k++) {
          if ((vec[i] * vec[j] * vec[k]) == n) {
            flag = 1;
            goto label;
          }
        }
      }
    }
    goto label;
  label:
    if (flag) {
      cout << "YES" << endl;
      cout << vec[i] << " " << vec[j] << " " << vec[k] << endl;
    } else
      cout << "NO" << endl;
  }
}
