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