#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int T;
  cin >> T;
  while (T--) {
    long long int n, k = 0, i, j, b, c, flag = 0, p = 0;
    cin >> n;
    vector<int> a;
    for (int i = 1; i <= sqrt(n); i++) {
      if (n % i == 0) {
        if (n / i == i)
          a.push_back(i);
        else {
          a.push_back(i);
          a.push_back(n / i);
        }
      }
    }
    sort(a.begin(), a.end());
    for (i = 0; i < a.size(); i++) {
      if (a[i] < 2)
        continue;
      else {
        for (j = 0; j < a.size(); j++) {
          if (a[j] < 2)
            continue;
          else {
            for (k = 0; k < a.size(); k++) {
              if (a[k] < 2)
                continue;
              else if (a[i] * a[j] * a[k] == n && a[i] != a[j] &&
                       a[j] != a[k] && a[k] != a[i]) {
                cout << "YES" << endl;
                cout << a[i] << " " << a[j] << " " << a[k] << endl;
                flag = 1;
                break;
              }
            }
          }
          if (flag == 1) break;
        }
      }
      if (flag == 1) break;
    }
    if (flag == 0) cout << "NO" << endl;
  }
  return 0;
}
