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