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