#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 2; i <= sqrt(n); i++) {
      while (n % i == 0) {
        v.push_back(i);
        n /= i;
      }
    }
    if (n > 1) v.push_back(n);
    set<int> s;
    int cur = 1;
    for (auto it : v) {
      cur = cur * it;
      if (s.size() <= 1 && s.find(cur) == s.end()) {
        s.insert(cur);
        cur = 1;
      }
    }
    if (cur == 1 || s.find(cur) != s.end()) {
      cout << "NO\n";
    } else {
      s.insert(cur);
      cout << "YES\n";
      for (auto it : s) cout << it << " ";
      cout << "\n";
    }
  }
}
