#include <bits/stdc++.h>
using namespace std;
int ans[110];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    int cnt = 0;
    scanf("%d", &n);
    int tmp = sqrt(n);
    for (int i = 2; i <= tmp; i++) {
      while (n % i == 0) {
        ans[++cnt] = i;
        n /= i;
      }
    }
    if (n > 1) {
      ans[++cnt] = n;
    }
    if (cnt < 3) {
      printf("NO\n");
    } else {
      int pos = 3;
      if (ans[2] == ans[1]) {
        ans[2] *= ans[3];
        pos = 4;
      }
      int tmpt = 1;
      for (int i = pos; i <= cnt; i++) {
        tmpt *= ans[i];
      }
      if (tmpt == 1 || ans[2] == tmpt || ans[3] == ans[1]) {
        printf("NO\n");
      } else {
        printf("YES\n%d %d %d\n", ans[1], ans[2], tmpt);
      }
    }
  }
  return 0;
}
