#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n--) {
    int flag = 0;
    long long int q;
    cin >> q;
    for (long int i = 2; i <= sqrt(q); i++) {
      if (q % i == 0) {
        for (long int j = i + 1; j <= sqrt(q / i); j++) {
          if ((q / i) % j == 0 && j != ((q / i) / j)) {
            flag = 1;
            cout << "YES" << endl;
            cout << i << " " << j << " " << (q / i) / j << endl;
            break;
          }
        }
        if (flag == 1) break;
      }
    }
    if (flag == 0) cout << "NO" << endl;
  }
}
