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