Problem: An agent called Cypher is decrypting a message, that contains a [composite number](https://en.wikipedia.org/wiki/Composite_number) n. All divisors of n, which are greater than 1, are placed in a circle. Cypher can choose the initial order of numbers in the circle.

In one move Cypher can choose two adjacent numbers in a circle and insert their [least common multiple](https://en.wikipedia.org/wiki/Least_common_multiple) between them. He can do that move as many times as needed.

A message is decrypted, if every two adjacent numbers are not coprime. Note that for such constraints it's always possible to decrypt the message.

Find the minimal number of moves that Cypher should do to decrypt the message, and show the initial order of numbers in the circle for that.

Input

The first line contains an integer t (1 ≤ t ≤ 100) — the number of test cases. Next t lines describe each test case.

In a single line of each test case description, there is a single composite number n (4 ≤ n ≤ 10^9) — the number from the message.

It's guaranteed that the total number of divisors of n for all test cases does not exceed 2 ⋅ 10^5.

Output

For each test case in the first line output the initial order of divisors, which are greater than 1, in the circle. In the second line output, the minimal number of moves needed to decrypt the message.

If there are different possible orders with a correct answer, print any of them.

Example

Input


3
6
4
30


Output


2 3 6 
1
2 4 
0
2 30 6 3 15 5 10 
0

Note

In the first test case 6 has three divisors, which are greater than 1: 2, 3, 6. Regardless of the initial order, numbers 2 and 3 are adjacent, so it's needed to place their least common multiple between them. After that the circle becomes 2, 6, 3, 6, and every two adjacent numbers are not coprime.

In the second test case 4 has two divisors greater than 1: 2, 4, and they are not coprime, so any initial order is correct, and it's not needed to place any least common multiples.

In the third test case all divisors of 30 greater than 1 can be placed in some order so that there are no two adjacent numbers that are coprime.

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main{
    static long ncr(long n, long k) 
    { 
        long res = 1; 
      
        // Since C(n, k) = C(n, n-k) 
        if ( k > n - k ) 
            k = n - k; 
      
        // Calculate value of [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1] 
        for (long i = 0; i < k; ++i) 
        { 
            res *= (n - i); 
            res /= (i + 1); 
        } 
      
        return res; 
    } 
    public static void sort(long []arr){
        ArrayList<Long> list=new ArrayList<>();
        for(int i=0;i<arr.length;i++)
            list.add(arr[i]);
        Collections.sort(list);
        for(int i=0;i<arr.length;i++)
            arr[i]=list.get(i);
    }
    public static void swap(char []chrr, int i, int j){
        char temp=chrr[i];
        chrr[i]=chrr[j];
        chrr[j]=temp;
    }
    public static int num(int n){
        int a=0;
        while(n>0){
            a+=(n&1);
            n>>=1;
        }
        return a;
    }
    static class Pair{
        int a, b;
        Pair(int a,int b){
            this.a=a;
            this.b=b;
        }
    }
        // public int compareTo(Pair p){
        //     return (b-p.b);
        // }
        // public int hashCode(){
        //     int hashcode = (a+" "+b).hashCode();
        //     return hashcode;
        // }
         
        // public boolean equals(Object obj){
        //     if (obj instanceof Pair) {
        //         Pair p = (Pair) obj;
        //         return (p.a==this.a && p.b == this.b);
        //     }
        //     return false;
        // }
 
    static boolean isPrime(int n) { 
        if (n <= 1) 
            return false; 
        if (n <= 3) 
            return true; 
        if (n % 2 == 0 || n % 3 == 0) 
            return false; 
        for (int i = 5; i * i <= n; i = i + 6) 
            if (n % i == 0 || n % (i + 2) == 0) 
                return false; 
        return true; 
    } 
    static int gcd(int a, int b) { 
        if (b == 0) 
            return a; 
        return a>b?gcd(b, a % b):gcd(a, b % a);  
    } 
    static long fast_pow(long base,long n,long M){
        if(n==0)
           return 1;
        if(n==1)
        return base;
        long halfn=fast_pow(base,n/2,M);
        if(n%2==0)
            return ( halfn * halfn ) % M;
        else
            return ( ( ( halfn * halfn ) % M ) * base ) % M;
    }
    static long modInverse(long n,long M){
        return fast_pow(n,M-2,M);
    }
    public static void feedArr(long []arr,InputReader sc){
        for(int i=0;i<arr.length;i++)
            arr[i]=sc.nextLong();
    }
    public static void feedArr(double []arr,InputReader sc){
        for(int i=0;i<arr.length;i++)
            arr[i]=sc.nextDouble();
    }
    public static void feedArr(int []arr,InputReader sc){
        for(int i=0;i<arr.length;i++)
            arr[i]=sc.nextInt();
    }
    public static void feedArr(String []arr,InputReader sc){
        for(int i=0;i<arr.length;i++)
            arr[i]=sc.next();
    }
    public static String printArr(int []arr){
        StringBuilder sbr=new StringBuilder();
        for(int i:arr)
            sbr.append(i+" ");
        return sbr.toString();
    }
    public  static String printArr(long []arr){
        StringBuilder sbr=new StringBuilder();
        for(long i:arr)
            sbr.append(i+" ");
        return sbr.toString();
    }
    public static String printArr(String []arr){
        StringBuilder sbr=new StringBuilder();
        for(String i:arr)
            sbr.append(i+" ");
        return sbr.toString();
    }
    public static String printArr(double []arr){
        StringBuilder sbr=new StringBuilder();
        for(double i:arr)
            sbr.append(i+" ");
        return sbr.toString();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
 
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
 
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }
    static int L,R,top,bottom;
    static int cnt,edge;
    public static void solve(InputReader sc, PrintWriter pw) {
        int t=sc.nextInt();
        // int t=1;
        u:while(t-->0){
            long N=sc.nextLong();
            long n=N;
            List<Long> list=new ArrayList<>();
            HashSet<Long> fact=new HashSet<>();
            for(long i=2l;i*i<=n;i++){
                if(n%i==0){
                    list.add(i);
                    while(n%i==0)
                        n/=i;
                }
            }
            if(n>1l)
                list.add(n);
            n=N;
            fact.add(n);
            for(long i=2l;i*i<=n;i++){
                if(n%i==0){
                    fact.add(i);
                    if(n/i!=i)
                        fact.add(n/i);
                }
            }
            if(list.size()==1){
                for(long i:fact)
                    pw.print(i+" ");
                pw.println();
                pw.println(0);
                continue u;
            }
            if(list.size()==2){
                // System.out.println(list);
                List<Long> mid=new ArrayList<>();
                long mul=list.get(0)*list.get(1);
                for(long j:fact){
                    if(j%mul==0){
                        // System.out.println("Hi");
                        mid.add(j);
                    }
                }
                for(int i=0;i<2;i++){
                    for(long j:fact){
                        if(j%(list.get(0)*list.get(1))==0)
                            continue;
                        else if(j%list.get(i)==0)
                            pw.print(j+" ");
                    }
                    if(i==0)
                        pw.print(mid.get(0)+" ");
                }
                if(mid.size()>=2){
                    for(int i=1;i<mid.size();i++)
                        pw.print(mid.get(i)+" ");
                    pw.println();
                    pw.println(0);
                }
                else{
                    pw.println();
                    pw.println(1);
                }
            }
            else{
                List<Long> mid;
                List<Long> rem;
                int size=list.size();
                for(int i=0;i<size;i++){
                    mid=new ArrayList<>();
                    rem=new ArrayList<>();
                    for(long j:fact){
                        if(j%(list.get(i)*list.get((i+1)%size))==0){
                            mid.add(j);
                            rem.add(j);
                        }
                        else if(j%(list.get(i)*list.get((i-1+size)%size))==0)
                            continue;
                        else if(j%list.get(i)==0){
                            pw.print(j+" ");
                            rem.add(j);
                        }
                    }
                    for(long j:mid)
                        pw.print(j+" ");
                    for(long j:rem)
                        fact.remove(j);
                }
                pw.println();
                pw.println(0);
            }
        }
    }
}