#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  for (; b; a %= b, swap(a, b))
    ;
  return a;
}
vector<long long> pr;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  pr.push_back(2);
  for (long long i = 3; i * i <= 1000000000; i++) {
    bool flag = false;
    for (int j = 0; j < pr.size() && pr[j] * pr[j] <= i; j++) {
      if (i % pr[j] == 0) {
        flag = true;
        break;
      }
    }
    if (!flag) pr.push_back(i);
  }
  int t;
  cin >> t;
  while (t--) {
    map<long long, int> mp;
    long long n;
    cin >> n;
    for (int i = 0; i < pr.size(); i++) {
      while (n % pr[i] == 0) {
        n /= pr[i];
        mp[pr[i]]++;
      }
    }
    if (n != 1) mp[n]++;
    if (mp.size() >= 3) {
      cout << "YES\n";
      long long tmp = 1;
      int cnt = 0;
      for (auto &it : mp) {
        if (cnt < 3) tmp = 1;
        for (int i = 0; i < it.second; i++) tmp *= it.first;
        if (cnt < 2) {
          cout << tmp << ' ';
        }
        cnt++;
      }
      cout << tmp << ' ';
      cout << '\n';
    } else if (mp.size() == 2) {
      int twoCnt = 0;
      bool flag = false;
      for (auto &it : mp) {
        if (it.second >= 3)
          flag = true;
        else if (it.second == 2)
          twoCnt++;
      }
      if (!flag) {
        if (twoCnt == 2) {
          cout << "YES\n";
          long long f1 = (*mp.begin()).first;
          long long f2 = (*++mp.begin()).first;
          cout << f1 << ' ' << f2 << ' ' << f1 * f2 << '\n';
        } else
          cout << "NO\n";
        continue;
      }
      cout << "YES\n";
      bool hasPrinted = false;
      for (auto &it : mp) {
        if (it.second >= 3 && !hasPrinted) {
          cout << it.first << ' ';
          long long tmp = 1;
          for (int i = 0; i < it.second - 1; i++) tmp *= it.first;
          cout << tmp << ' ';
          hasPrinted = true;
        } else {
          long long tmp = 1;
          for (int i = 0; i < it.second; i++) tmp *= it.first;
          cout << tmp << ' ';
        }
      }
      cout << '\n';
    } else if (mp.size() == 1) {
      auto it = *mp.begin();
      if (it.second < 6) {
        cout << "NO\n";
        continue;
      }
      cout << "YES\n";
      long long num = it.first;
      cout << num << ' ' << num * num << ' ';
      long long tmp = 1;
      for (int i = 0; i < it.second - 3; i++) tmp *= it.first;
      cout << tmp << '\n';
    } else
      cout << "NO\n";
  }
}
