#include <bits/stdc++.h>
int n, a[105], m;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    int s1 = 0, s2 = 0, s3 = 0;
    m = a[i];
    for (int j = 2; j * j <= m; j++) {
      if (m % j == 0) {
        if (s1 == 0)
          s1 = j;
        else
          s2 = j;
        m /= j;
      }
      if (s2 != 0 && m != 1) {
        s3 = a[i] / (s1 * s2);
        if (s2 == s3) s3 = 0;
        break;
      }
    }
    if (s1 * s2 * s3 != 0)
      printf("YES\n%d %d %d", s1, s2, s3);
    else
      printf("NO");
    if (i != n) printf("\n");
  }
  scanf("\n");
}
