#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  int t;
  int n;
  cin >> t;
  while (t--) {
    cin >> n;
    set<int> used;
    for (int i = 2; i * i <= n; i++) {
      if (n % i == 0 && !used.count(i)) {
        used.insert(i);
        n /= i;
        break;
      }
    }
    for (int i = 2; i * i <= n; i++) {
      if (n % i == 0 && !used.count(i)) {
        used.insert(i);
        n /= i;
        break;
      }
    }
    if (int(used.size()) < 2 || n == 1 || used.count(n))
      cout << "NO" << endl;
    else {
      cout << "YES" << endl;
      set<int>::iterator iter;
      iter = used.begin();
      used.insert(n);
      for (; iter != used.end(); iter++) {
        cout << *iter << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
