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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long POW(long long x, long long y);
long long mf(long long x, long long mod);
long long mi(long long x, long long mod);
long long C(long long x, long long y, long long mod);
long long bpow(long long x, long long y, long long mod);
long long POW(long long x, long long y) { return bpow(x, y, LONG_LONG_MAX); }
long long mf(long long x, long long mod = 1000000007) {
  if (x < 2) return 1;
  return (x * mf(x - 1, mod)) % mod;
}
long long mi(long long x, long long mod = 1000000007) {
  return bpow(x, mod - 2, mod);
}
long long C(long long x, long long y, long long mod = 1000000007) {
  if (x < y) return 0;
  long long n1 = mf(x, mod);
  long long n2 = mi(mf(y, mod), mod);
  long long n3 = mi(mf(x - y, mod), mod);
  long long res = (n1 * n2) % mod;
  res = (res * n3) % mod;
  return res;
}
long long bpow(long long x, long long y, long long mod = 1000000007) {
  x %= mod;
  long long res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    y >>= 1;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long q;
  cin >> q;
  for (long long _ = 1; _ <= q; _++) {
    long long n;
    cin >> n;
    ;
    vector<long long> f;
    for (long long i = 2; i * i <= n; i++) {
      if (n % i == 0) {
        if (i * i == n) {
          f.push_back(i);
        } else {
          f.push_back(i);
          f.push_back(n / i);
        }
      }
    }
    f.push_back(n);
    sort(f.begin(), f.end());
    map<long long, long long> mpf;
    for (auto it : f) {
      mpf[it] = -1;
    }
    for (auto it : f) {
      if (mpf[it] == -1) {
        for (long long j = 2; j * j <= it; j++) {
          if (it % j == 0) {
            mpf[it] = j;
            break;
          }
        }
        if (mpf[it] == -1) {
          mpf[it] = it;
        }
      }
    }
    vector<long long> cycles;
    for (auto it : f) {
      if (mpf[it] == it) {
        cycles.push_back(it);
      }
    }
    map<long long, vector<long long> > mpf_cycle;
    if (cycles.size() == 1) {
      for (auto it : f) {
        cout << it << ' ';
      }
      cout << "\n";
      cout << 0 << "\n";
    } else if (cycles.size() == 2) {
      if (cycles[0] * cycles[1] == n) {
        for (auto it : f) {
          cout << it << ' ';
        }
        cout << "\n";
        cout << 1 << "\n";
      } else {
        for (auto it : f) {
          mpf_cycle[mpf[it]].push_back(it);
        }
        for (auto it : mpf_cycle[cycles[0]]) {
          if (it == n || it == cycles[0] * cycles[1]) {
          } else {
            cout << it << ' ';
          }
        }
        cout << cycles[0] * cycles[1] << ' ';
        for (auto it : mpf_cycle[cycles[1]]) {
          cout << it << ' ';
        }
        cout << n << "\n";
        cout << 0 << "\n";
      }
    } else {
      for (auto it : f) {
        mpf_cycle[mpf[it]].push_back(it);
      }
      for (long long i = 0; i < cycles.size() - 1; i++) {
        long long c1 = cycles[i] * cycles[i + 1];
        for (auto it : mpf_cycle[cycles[i]]) {
          if (it == n || it == c1) {
          } else {
            cout << it << ' ';
          }
        }
        cout << c1 << ' ';
      }
      for (auto it : mpf_cycle[cycles[cycles.size() - 1]]) {
        cout << it << ' ';
      }
      cout << n << "\n";
      cout << 0 << "\n";
    }
  }
}