#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  cin >> q;
  while (q--) {
    cin >> n;
    vector<int> res;
    for (int i = 2; res.size() < 2 && i * i < n; ++i) {
      if (n % i == 0) {
        res.push_back(i);
        n /= i;
      }
    }
    res.push_back(n);
    if (res.size() != 3) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
      cout << res[0] << " " << res[1] << " " << res[2] << endl;
    }
  }
}
