#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, i;
  long n, d, arr[2];
  cin >> t;
  while (t--) {
    cin >> n;
    i = 0;
    for (d = 2; d * d < n && i < 2; d++) {
      if (n % d == 0) {
        arr[i++] = d;
        n /= d;
      }
    }
    if (i == 2)
      cout << "YES\n" << arr[0] << ' ' << arr[1] << ' ' << n << '\n';
    else
      cout << "NO\n";
  }
  return 0;
}
