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;
void cout_vector(vector<int> v) {
  for (long long unsigned i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << endl;
}
int sum_vector(vector<int> v) { return accumulate(v.begin(), v.end(), 0); }
void sort_vector(vector<int> &v) { sort(v.begin(), v.end()); }
void sort_comp(vector<int> &v, bool func(int, int)) {
  sort(v.begin(), v.end(), func);
}
bool comp(int a, int b) {
  if (a % 2 == 0 && b % 2) return true;
  if (b % 2 == 0 && a % 2) return false;
  return a < b;
}
long long gcd(long long a, long long b) {
  while (a) {
    long long temp = a;
    a = b % a;
    b = temp;
  }
  return b;
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
string binary(long long num) {
  string ans = "";
  do {
    ans = to_string(num % 2) + ans;
    num /= 2;
  } while (num);
  return ans;
}
void solve() {
  int n;
  cin >> n;
  vector<int> divisors = {n};
  vector<int> fac;
  vector<bool> used = {1};
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      divisors.push_back(i);
      used.push_back(0);
      if (n != i * i) {
        divisors.push_back(n / i);
        used.push_back(0);
      }
    }
  }
  fac.push_back(divisors[1]);
  int rest = n / fac[0];
  while (rest != 1) {
    for (int i = 2; i * i <= rest + 3; i++) {
      if (rest % i == 0) {
        fac.push_back(i);
        rest /= i;
        break;
      }
      if ((i + 1) * (i + 1) > rest) {
        fac.push_back(rest);
        rest = 1;
      }
    }
  }
  sort_vector(fac);
  vector<int> uni_fac = {fac[0]};
  int last = fac[0];
  for (int num : fac) {
    if (num == last)
      ;
    else {
      last = num;
      uni_fac.push_back(last);
    }
  }
  uni_fac.push_back(uni_fac[0]);
  if (fac.size() == 2 && (fac[0] != fac[1])) {
    cout_vector(divisors);
    cout << 1 << endl;
  } else {
    for (int i = 0; i < int(uni_fac.size()) - 1; i++) {
      cout << uni_fac[i] << " ";
      for (int j = 0; j < int(divisors.size()); j++) {
        if ((!used[j]) && (divisors[j] % uni_fac[i] == 0)) {
          if (divisors[j] != uni_fac[i] * uni_fac[i + 1] &&
              divisors[j] != uni_fac[i]) {
            cout << divisors[j] << " ";
          }
          used[j] = 1;
        }
      }
      if ((i == 0 || (i != int(uni_fac.size()) - 2)) &&
          divisors[0] != uni_fac[i] * uni_fac[i + 1])
        cout << uni_fac[i] * uni_fac[i + 1] << " ";
    }
    cout << divisors[0];
    cout << endl << 0 << endl;
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}