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