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.util.*;
import java.io.*;

public class E_1419 {
	
	public static ArrayList<Integer> factorsDiv(int n) {
		ArrayList<Integer> factors = new ArrayList<>();
		for(int i = 2; 1l * i * i <= n; i++)
			if(n % i == 0) {
				factors.add(i);
				if(1l * i * i != n)
					factors.add(n / i);
			}
		factors.add(n);
		return factors;
	}
	
	static ArrayList<Integer> primes;
	static boolean[] isPrime;
	public static void sieve(int n) {
		primes = new ArrayList<Integer>();
		isPrime = new boolean[n + 1];
		Arrays.fill(isPrime, true);
		isPrime[0] = isPrime[1] = false;
		for(int i = 2; i <= n; i++) {
			if(isPrime[i]) {
				if(1l * i * i <= n)
					for(int j = i * i; j <= n; j += i)
						isPrime[j] = false;
				primes.add(i);
			}
		}
	}
	
	static ArrayList<Integer> primeFactor;
	static ArrayList<Integer> primeFactorCount;
	public static void primeFactors(int n) {
		primeFactor = new ArrayList<>();
		primeFactorCount = new ArrayList<>();
		
		for(int p : primes) {
			if(n == 1)
				break;
			if(1l * p * p > n)
				break;
			
			int cnt = 0;
			while(n % p == 0) {
				n /= p;
				cnt++;
			}
			
			if(cnt > 0) {
				primeFactor.add(p);
				primeFactorCount.add(cnt);
			}
		}
		
		if(n > 1) {
			primeFactor.add(n);
			primeFactorCount.add(1);
		}
	}
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		sieve((int)Math.sqrt(1e9) + 5);
		int t = sc.nextInt();
		while(t-->0) {
			int n = sc.nextInt();
			ArrayList<Integer> factors = factorsDiv(n);
			Collections.sort(factors);
			primeFactors(n);
			if(primeFactor.size() == 1) {
				for(int i = 0; i < factors.size(); i++)
					pw.print(factors.get(i) + (i == factors.size() - 1 ? "\n" : " "));
				pw.println(0);
				continue;
			} else if(primeFactor.size() == 2 && factors.size() == 3) {
				for(int i = 0; i < factors.size(); i++)
					pw.print(factors.get(i) + (i == factors.size() - 1 ? "\n" : " "));
				pw.println(1);
				continue;
			}
			
			int size = primeFactor.size();
			TreeSet<Integer>[] primeown = new TreeSet[size];
			TreeSet<Integer>[][] twoown = new TreeSet[size][size];
			
			for(int i = 0; i < size; i++)
				primeown[i] = new TreeSet<>();
			
			for(int i = 0; i < size; i++)
				for(int j = 0; j < size; j++)
					twoown[i][j] = new TreeSet<>();
			
			for(int i = 0; i < factors.size(); i++) {
				if(factors.get(i) == n)
					continue;
				for(int j = 0; j < size; j++)
					if(factors.get(i) % primeFactor.get(j) == 0)
						primeown[j].add(factors.get(i));
 				for(int j = 0; j < size; j++)
 					for(int k = 0; k < size; k++)
 						if(j != k)
							if(factors.get(i) % primeFactor.get(j) == 0 && factors.get(i) % primeFactor.get(k) == 0) {
								twoown[j][k].add(factors.get(i));
								twoown[k][j].add(factors.get(i));
							}

			}
			
			TreeSet<Integer> taken = new TreeSet<>();
			for(int i = 0; i < size; i++)
				taken.add(primeFactor.get(i));
			int[] ans = new int[factors.size()];
			int index = 0;
			for(int i = 0; i < size; i++) {
				if(i == size - 1) {
					int common = n;
					while(!primeown[i].isEmpty()) {
						int x = primeown[i].pollFirst();
						if(!taken.contains(x)) {
							taken.add(x);
							ans[index++] = x;
						}
					}
					ans[index++] = primeFactor.get(i);
					ans[index++] = common;
				} else {
					int common = 0;
					while(!twoown[i][i + 1].isEmpty()) {
						int x = twoown[i][i + 1].pollFirst();
						if(!taken.contains(x)) {
							taken.add(x);
							common = x;
							break;
						}
					}
					while(!primeown[i].isEmpty()) {
						int x = primeown[i].pollFirst();
						if(!taken.contains(x)) {
							taken.add(x);
							ans[index++] = x;
						}
					}
					ans[index++] = primeFactor.get(i);
					ans[index++] = common;
				}
			}
			
			for(int i = 0; i < factors.size(); i++)
				pw.print(ans[i] + (i == factors.size() - 1 ? "\n" : " "));
			pw.println(0);
		}
		
		pw.flush();
	}

	public static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		public Integer[] nextIntegerArray(int n) throws IOException {
			Integer[] array = new Integer[n];
			for (int i = 0; i < n; i++)
				array[i] = new Integer(nextInt());
			return array;
		}

		public long[] nextLongArray(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		public double[] nextDoubleArray(int n) throws IOException {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		public static int[] shuffle(int[] a) {
			int n = a.length;
			Random rand = new Random();
			for (int i = 0; i < n; i++) {
				int tmpIdx = rand.nextInt(n);
				int tmp = a[i];
				a[i] = a[tmpIdx];
				a[tmpIdx] = tmp;
			}
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}