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