#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, ans = 0, i;
    cin >> n;
    vector<int> v;
    for (i = 2; i < pow(n, 0.5); i++) {
      if (ans == 2) break;
      if (n % i == 0) {
        ans++;
        n = n / i;
        v.push_back(i);
      }
    }
    if (v.size() == 2) {
      v.push_back(n);
      cout << "YES"
           << "\n";
      for (i = 0; i < 3; i++) {
        cout << v[i] << " ";
      }
      cout << "\n";
    } else
      cout << "NO"
           << "\n";
  }
  return 0;
}
