#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    set<int> values;
    for (int i = 2; i * i <= n; i++) {
      if (n % i == 0) {
        values.insert(i);
        n /= i;
        break;
      }
    }
    for (int i = 2; i * i <= n; i++) {
      if (n % i == 0 && !values.count(i)) {
        values.insert(i);
        n /= i;
        break;
      }
    }
    if ((int)values.size() < 2 || n == 1 || values.count(n)) {
      cout << "NO" << endl;
    } else {
      values.insert(n);
      cout << "YES" << endl;
      for (auto it : values) cout << it << " ";
      cout << endl;
    }
  }
}
