#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  long long int ans[3];
  long long int count = 0;
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      n = n / i;
      ans[count] = i;
      count++;
    }
    if (count == 3) {
      break;
    }
  }
  if (count == 3 && n > 2) {
    ans[2] = ans[2] * n;
  } else if (count < 3 && n > 2) {
    ans[count] = n;
    count++;
  }
  if (count == 3 && ans[0] != ans[1] && ans[1] != ans[2] && ans[2] != ans[0]) {
    cout << "YES" << endl;
    cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
  } else
    cout << "NO" << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
