#include <bits/stdc++.h>
using namespace std;
inline int mulmd(long long a, long long b) {
  long long ret = (a * b) % 1000000007;
  return (int)ret;
}
inline int power(long long x, long long y, int m) {
  long long res = 1;
  x = x % m;
  while (y > 0) {
    if (y & 1) {
      res = mulmd(res, x);
    }
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int)res;
}
inline int submd(long long a, long long b) {
  long long ret = (a - b);
  if (ret < 0) ret += 1000000007;
  return (int)ret;
}
inline int addmd(long long a, long long b) {
  long long ret = (a + b) % 1000000007;
  return (int)ret;
}
inline int invPow(long long a) { return power(a, 1000000007 - 2, 1000000007); }
inline int divmd(long long a, long long b) {
  long long ret = mulmd(a, invPow(b));
  return (int)ret;
}
const int N = 1e5 + 5;
int arr[N];
void solve() {
  int n;
  cin >> n;
  vector<int> ans;
  int r = n;
  for (int i = 2; i <= 100000; i++) {
    if (n % i == 0) {
      n /= i;
      ans.push_back(i);
      break;
    }
  }
  if (ans.size() < 1) {
    cout << "NO\n";
    return;
  }
  for (int i = 2; i <= 100000; i++) {
    if (n % i == 0 && i != ans[0]) {
      n /= i;
      ans.push_back(i);
      break;
    }
  }
  if (ans.size() < 2) {
    cout << "NO\n";
    return;
  }
  int prod = ans[0] * ans[1];
  int fin = r / prod;
  if (fin != ans[0] && fin != ans[1] && fin >= 2) {
    cout << "YES\n";
    cout << ans[0] << " " << ans[1] << " " << fin << "\n";
  } else {
    cout << "NO\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
