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