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