#include <bits/stdc++.h>   using namespace std;   map<int, int> mp;   set<int> s;   int main(void) {     int q;     scanf( %d , &q);     while (q--) {       mp.clear();       int x;       scanf( %d , &x);       int t = x;       int lim = sqrt(t);       for (int i = 2; i <= lim; i++) {         while (t % i == 0) {           mp[i]++;           t /= i;         }       }       if (1 < t) mp[t]++;       s.clear();       for (int i = 2; i <= lim; i++) {         if (x % i == 0) {           s.insert(i);           s.insert(x / i);         }       }       s.insert(x);       vector<int> rep;       for (auto e : mp) rep.push_back(e.first);       if (rep.size() == 2) {         int mult = 1;         for (auto e : mp) mult *= e.first;         vector<int> ds;         if (mult == x) {           printf( %d  , mult);           for (int p : rep) {             for (int div : s) {               if (div % p == 0) {                 if (div != mult) {                   printf( %d  , div);                 }                 ds.push_back(div);               }             }             for (int e : ds) s.erase(e);             ds.clear();           }           printf(  n1 n );         } else {           printf( %d  , x);           vector<int> ds;           for (int p : rep) {             for (int div : s) {               if (div % p == 0) {                 if (div != mult) {                   if (div != x) {                     printf( %d  , div);                   }                 }                 ds.push_back(div);               }             }             for (int e : ds) s.erase(e);             ds.clear();             if (p != rep.back()) printf( %d  , mult);           }           printf(  n0 n );         }       } else if (rep.size() == 1) {         for (int div : s) {           printf( %d  , div);         }         printf(  n0 n );       } else {         map<int, int> joint;         for (int i = 0; i < rep.size(); i++) {           joint[rep[i] * rep[(i + 1) % rep.size()]] = true;         }         vector<int> ds;         for (int i = 0; i < rep.size(); i++) {           for (int div : s) {             if (div % rep[i] == 0) {               if (joint.count(div) == 0) {                 printf( %d  , div);               }               ds.push_back(div);             }           }           printf( %d  , rep[i] * rep[(i + 1) % rep.size()]);           for (int e : ds) s.erase(e);           ds.clear();         }         printf(  n0 n );       }     }   }   