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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

public class Task6 {

    public static void main(String[] args) throws IOException {
        new Task6().solve();
    }

    private void solve() throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        int t = Integer.parseInt(f.readLine());
        int upTo = 2;
        while (upTo * upTo <= 1000000000) {
            upTo++;
        }

        boolean[] isNotPrime = new boolean[upTo];
        ArrayList<Integer> primes = new ArrayList<Integer>();
        for (int i = 2; i < upTo; i++) {
            if (isNotPrime[i]) continue;
            primes.add(i);
            for (int j = 2 * i; j < upTo; j += i) {
                isNotPrime[j] = true;
            }
        }
        for (int t1 = 0 ;t1 < t; t1++) {
            int n = Integer.parseInt(f.readLine());
            if (isPrime(n)) {
                out.println(n);
                out.println(1);
                continue;
            }



            ArrayList<int[]> primeFactors = new ArrayList<int[]>();
            int i = 2;
            int orgN = n;
            for (int prime : primes) {
                if (n % prime == 0) {
                    int[] ar = {prime, 1};
                    n /= prime;
                    while (n % prime == 0) {
                        n /= prime;
                        ar[1]++;
                    }
                    primeFactors.add(ar);
                }
            }
            if (n != 1) {
                int[] prime = {n, 1};
                primeFactors.add(prime);
            }

            ArrayList<Integer> nodes = new ArrayList<Integer>();
            /*
            if (primeFactors.size() == 2) {
                int[] prime = primeFactors.get(0);
                for (int k = 1; k <= prime[1]; k++) nodes.add(pow(prime[0], k));
                int[] otherPrime = primeFactors.get(1);
                for (int k = 1; k <= prime[1]; k++) {
                    for (int l = 1; l <= otherPrime[1]; l++) {
                        nodes.add(pow(prime[0], k) * pow(otherPrime[0], l));
                    }
                }

                for (int k = 1; k <= otherPrime[1]; k++) nodes.add(nodes.size() - 1, pow(otherPrime[0], k));

                out.print(nodes.get(0));
                for (i = 1; i < nodes.size(); i++) {
                    out.print(" " + nodes.get(i));
                }
                out.println();
                if (nodes.get(0) == prime[0] && nodes.get(nodes.size() - 1) == otherPrime[0]) out.println(1);
                else out.println(1);
                continue;
            } */

            ArrayList<Integer> div = new ArrayList<Integer>();
            generateDivisors(div, primeFactors, 0, 1, orgN);

            HashMap<Integer, Boolean> visited = new HashMap<Integer, Boolean>();
            nodes.add(orgN);
            for (i = 0; i < primeFactors.size() - 1; i++) {
                int[] prime = primeFactors.get(i);
                int nextPrime = primeFactors.get(i + 1)[0];
                int addAtEnd = -1;
                for (int divisor : div) {
                    if (visited.get(divisor) != null && visited.get(divisor)) continue;
                    if (divisor % prime[0] == 0 && divisor % nextPrime == 0) {
                        visited.put(divisor, true);
                        addAtEnd = divisor;
                        break;
                    }
                }

                for (int divisor : div) {
                    if (visited.get(divisor) != null && visited.get(divisor)) continue;
                    if (divisor % prime[0] == 0) {
                        visited.put(divisor, true);
                        nodes.add(divisor);
                    }
                }
                /*
                for (int k = 1; k <= prime[1]; k++) nodes.add(pow(prime[0], k));
                for (int j = i + 2; j < primeFactors.size(); j++) {
                    if (j == primeFactors.size() - 1 && i == 0) continue;
                    int[] otherPrime = primeFactors.get(j);
                    for (int k = 1; k <= prime[1]; k++) {
                        for (int l = 1; l <= otherPrime[1]; l++) {
                            nodes.add(pow(prime[0], k) * pow(otherPrime[0], l));
                        }
                    }
                }

                int[] otherPrime = primeFactors.get(i + 1);
                for (int k = 1; k <= prime[1]; k++) {
                    for (int l = 1; l <= otherPrime[1]; l++) {
                        nodes.add(pow(prime[0], k) * pow(otherPrime[0], l));
                    }
                } */

                if (addAtEnd != -1) nodes.add(addAtEnd);
            }

            for (int divisor : div) {
                if (visited.get(divisor) != null && visited.get(divisor)) continue;
                nodes.add(divisor);
            }

            /*
            int[] prime = primeFactors.get(primeFactors.size() - 1);
            for (int k = 1; k <= prime[1]; k++) nodes.add(pow(prime[0], k));
            int[] otherPrime = primeFactors.get(0);
            for (int k = 1; k <= prime[1]; k++) {
                for (int l = 1; l <= otherPrime[1]; l++) {
                    nodes.add(pow(prime[0], k) * pow(otherPrime[0], l));
                }
            } */

            out.print(nodes.get(0));
            for (i = 1; i < nodes.size(); i++) {
                out.print(" " + nodes.get(i));
            }
            out.println();

            if (primeFactors.size() == 2 && primeFactors.get(0)[1] == 1 && primeFactors.get(1)[1] == 1) out.println(1);
            else out.println(0);

        }

        out.close();
    }

    private void generateDivisors(ArrayList<Integer> divisors, ArrayList<int[]> primeFactors, int index, int num, int wholeNum) {
        if (index >= primeFactors.size()) {
            if (num != 1  && num != wholeNum) divisors.add(num);
            return;
        }

        int[] prime = primeFactors.get(index);
        for (int i = 0; i <= prime[1]; i++) {
            generateDivisors(divisors, primeFactors, index + 1, num, wholeNum);
            num *= prime[0];
        }
    }

    private static int pow(int num, int power) {
        int res = 1;
        while (power > 0) {
            res *= num;
            power--;
        }

        return res;
    }

    private boolean isPrime(int num) {
        for (int i = 2; i * i <= num; i++) {
            if (num % i == 0) return false;
        }

        return true;
    }
}