#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  ;
  int q;
  cin >> q;
  while (q--) {
    long long n;
    cin >> n;
    vector<long long> ans;
    for (long long i = 2; i <= sqrt(n); i++) {
      if (n % i == 0) {
        ans.push_back(i);
        n = n / i;
      }
      if (n == 1) break;
      if (ans.size() == 2) break;
    }
    if (ans.size() < 2 || n == ans[0] || n == 1 || n == ans[1])
      cout << "NO" << endl;
    else {
      cout << "YES" << endl << ans[0] << " " << ans[1] << " " << n << endl;
    }
  }
}
