#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, MOD = 1e9 + 7;
int t, n, a, b, c;
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 2; i * i <= n; ++i)
      if (n % i == 0) {
        a = i;
        break;
      }
    if (a)
      for (int i = 2; i * i <= n / a; ++i)
        if ((n / a) % i == 0 && a != i) {
          b = i;
          break;
        }
    if (a && b && a != b && a != n / (a * b) && b != n / (a * b) &&
        n % (a * b) == 0)
      cout << "YES" << endl << a << " " << b << " " << n / (a * b) << endl;
    else
      puts("NO");
  }
  return 0;
}
