#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    set<int> s;
    int count = 0;
    int a;
    cin >> a;
    for (int i = 2; i * i <= a; i++) {
      if (a % i == 0) {
        int u = a / i;
        s.insert(i);
        for (int j = i + 1; j * j <= u; j++) {
          if (u % j == 0) {
            s.insert(j);
            if (s.find(u / j) == s.end()) {
              count = 1;
              cout << "YES" << endl;
              cout << i << " " << j << " " << u / j << endl;
            }
            break;
          }
        }
      }
      if (count == 1) {
        break;
      }
    }
    if (count == 0) {
      cout << "NO" << endl;
    }
  }
  return 0;
}
