#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, fl = 0, fl2;
  cin >> t;
  while (t--) {
    fl = 0, fl2 = 0;
    cin >> n;
    vector<int> v;
    int p = n;
    for (int i = 2; i * i <= n; i++) {
      if (p % i == 0 && fl <= 1) {
        v.push_back(i);
        p /= i;
        fl++;
      }
    }
    if (v.size() == 2 && v[0] != v[1] && v[0] != p && v[1] != p) {
      cout << "YES" << endl;
      cout << v[0] << " " << v[1] << " " << p << endl;
    } else
      cout << "NO" << endl;
  }
}
