#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, i, x = 0, y = 0, j;
    cin >> n;
    for (i = 2; i <= sqrt(n); i++) {
      if (n % i == 0) {
        x = i;
        n /= i;
        for (j = i + 1; j <= sqrt(n); j++) {
          if (n % j == 0) {
            y = j;
            n /= j;
            break;
          }
        }
        if (x != 0 && y != 0) break;
      }
    }
    if (x != 0 && y != 0 && x != y && y != n && n != x)
      cout << "YES" << endl << x << " " << y << " " << n << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
