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