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.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

public class Decryption implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    int t = in.ni();
    while (t-- > 0) {
      int n = in.ni();
      List<Integer> divisors = getDivisors(n);
      List<Integer> primes = factorize(n);
      if (divisors.size() == 1) {
        out.println(divisors.get(0));
        out.println(0);
      } else if (primes.size() == 2 && divisors.size() > 3) {
        Set<Integer> d = new HashSet<>(divisors);
        List<Integer> result = new ArrayList<>();
        int p1 = primes.get(0), p2 = primes.get(1);
        result.add(p1);
        result.add(p1 * p2);
        result.add(p2);
        d.remove(p1);
        d.remove(p1 * p2);
        d.remove(p2);
        List<Integer> next = new ArrayList<>();
        for (int d_ : d) {
          if (d_ % p2 == 0 && d_ != n) {
            next.add(d_);
          }
        }
        d.removeAll(next);
        result.addAll(next);
        result.add(n);
        d.remove(n);
        result.addAll(d);
        for (int value : result) {
          out.print(value);
          out.print(' ');
        }
        out.println();
        out.println(0);
      } else if (primes.size() == 2 && divisors.size() == 3) {
        for (int d : divisors) {
          out.print(d);
          out.print(' ');
        }
        out.println();
        out.println(1);
      } else {
        Set<Integer> d = new HashSet<>(divisors);
        List<Integer> result = new ArrayList<>();
        for (int i = 0; i < primes.size(); i++) {
          int p1 = primes.get(i);
          int p2 = i == primes.size() - 1 ? primes.get(0) : primes.get(i + 1);
          result.add(p1);
          if (d.contains(p1 * p2)) {
            result.add(p1 * p2);
          }
          d.remove(p1);
          d.remove(p1 * p2);
        }
        for (int idx = 0; idx < result.size(); idx += 2) {
          int prime = result.get(idx);
          out.print(prime);
          out.print(' ');
          List<Integer> divisible = new ArrayList<>();
          for (int number : d) {
            if (number % prime == 0) {
              divisible.add(number);
            }
          }
          d.removeAll(divisible);
          for (int c : divisible) {
            out.print(c);
            out.print(' ');
          }
          if (idx + 1 < result.size()) {
            out.print(result.get(idx + 1));
          }
          out.print(' ');
        }
        out.println("\n" + 0);
      }
    }
  }

  private List<Integer> getDivisors(int n) {
    List<Integer> result = new ArrayList<>();
    for (int d = 1; d * d <= n; d++) {
      if (n % d == 0) {
         if (d > 1) {
           result.add(d);
         }
         if (d * d != n) {
           result.add(n / d);
         }
      }
    }
    return result;
  }

  private List<Integer> factorize(int n) {
    List<Integer> primes = new ArrayList<>();
    for (int d = 2; d * d <= n; d++) {
      if (n % d == 0) {
        primes.add(d);
        while (n % d == 0) {
          n /= d;
        }
      }
    }
    if (n > 1) {
      primes.add(n);
    }
    return primes;
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  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 ni() {
      return Integer.parseInt(next());
    }

    public long nl() {
      return Long.parseLong(next());
    }

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Decryption instance = new Decryption()) {
      instance.solve();
    }
  }
}