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;
const long long int MOD = 1000000007;
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  if (b == 0) return a;
  return gcd(b % a, a);
}
long long int my_pow(long long int a, long long int b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long int half = my_pow(a, b / 2);
  long long int ans = (half * half);
  if (b % 2) {
    ans = (ans * a);
  }
  return ans;
}
vector<pair<long long int, long long int> > func(long long int n) {
  vector<pair<long long int, long long int> > V;
  long long int count = 0;
  if (n % 2 == 0) {
    while (n % 2 == 0) {
      n /= 2;
      ++count;
    }
    V.push_back({2, count});
  }
  for (long long int i = 3; (i * i) <= n; i += 2) {
    if (n % i == 0) {
      count = 0;
      while (n % i == 0) {
        n /= i;
        ++count;
      }
      if (count > 0) V.push_back({i, count});
    }
  }
  if (n > 1) {
    V.push_back({n, 1});
  }
  return V;
}
void get_all_divisors(int curr_idx, long long int curr_ans,
                      vector<pair<long long int, long long int> > &V,
                      long long int l, long long int r,
                      vector<long long int> &R) {
  if (curr_idx > r) {
    R.push_back(curr_ans);
    return;
  }
  long long int count1 = V[curr_idx].second;
  long long int start_id = (curr_idx == l) ? 1 : 0;
  long long int prime1 = my_pow(V[curr_idx].first, start_id);
  for (int i = start_id; i < count1 + 1; i++) {
    get_all_divisors(curr_idx + 1, (curr_ans * prime1), V, l, r, R);
    prime1 *= V[curr_idx].first;
  }
}
inline void solve(long long int n) {
  vector<pair<long long int, long long int> > V = func(n);
  long long int len = V.size();
  if (len != 2) {
    if (V.size() == 1) {
      long long int len = V[0].second;
      for (int i = 0; i < len; i++) {
        cout << my_pow(V[0].first, i + 1) << " ";
      }
      cout << endl;
    } else {
      vector<long long int> R;
      get_all_divisors(0, 1, V, 0, len - 1, R);
      long long int last_val = (V[0].first * V[1].first);
      long long int end_val = (V[0].first * V[len - 1].first);
      long long int len1 = R.size();
      for (int j = 0; j < len1; j++) {
        if (last_val != R[j] && end_val != R[j]) {
          cout << R[j] << " ";
        }
      }
      cout << last_val << " ";
      for (long long int i = 1; i < (len - 1); ++i) {
        R.clear();
        get_all_divisors(i, 1, V, i, len - 1, R);
        last_val = (V[i].first * V[i + 1].first);
        len1 = R.size();
        for (int j = 0; j < len1; j++) {
          if (last_val != R[j]) {
            cout << R[j] << " ";
          }
        }
        cout << last_val << " ";
      }
      long long int prime1 = V[len - 1].first;
      for (long long int i = 1; i <= V[len - 1].second; ++i) {
        cout << prime1 << " ";
        prime1 *= V[len - 1].first;
      }
      cout << end_val << endl;
    }
    cout << 0 << endl;
    return;
  }
  long long int prime1 = V[0].first;
  long long int count1 = V[0].second;
  for (long long int j = 1; j <= count1; ++j) {
    cout << prime1 << " ";
    prime1 *= V[0].first;
  }
  long long int count2 = V[1].second;
  prime1 = 1;
  vector<long long int> div_list;
  for (long long int i = 1; i <= count1; ++i) {
    prime1 *= V[0].first;
    long long int prime2 = V[1].first;
    for (long long int j = 1; j <= count2; ++j) {
      div_list.push_back(prime1 * prime2);
      prime2 *= V[1].first;
    }
  }
  long long int len1 = div_list.size();
  for (int i = 1; i < len1; i++) {
    cout << div_list[i] << " ";
  }
  long long int prime2 = V[1].first;
  for (long long int j = 1; j <= count2; ++j) {
    cout << prime2 << " ";
    prime2 *= V[1].first;
  }
  cout << div_list[0] << endl;
  if ((V[0].second >= 2) || (V[1].second >= 2)) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}
int main() {
  long long int T;
  cin >> T;
  while (T--) {
    long long int n;
    cin >> n;
    solve(n);
  }
  return 0;
}