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>
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ld = long double;
using ll = long long;
using ull = unsigned long long;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll mod = 1e9 + 7;
void flush() { cout << flush; }
template <class T>
vector<T> vec(int len, T elem) {
  return vector<T>(len, elem);
}
template <class T>
inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline int popcount(T a) {
  return __builtin_popcountll(a);
}
template <class T>
inline T emod(T a, T p) {
  return (a % p + p) % p;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << '\n';
  for (auto v : vec) os << v << ' ';
  os << '\n';
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &vec) {
  os << "deq[";
  for (auto v : vec) os << v << ',';
  os << ']';
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &vec) {
  os << '{';
  for (auto v : vec) os << v << ',';
  os << '}';
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &vec) {
  os << '{';
  for (auto v : vec) os << v << ',';
  os << '}';
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &vec) {
  os << '{';
  for (auto v : vec) os << v << ',';
  os << '}';
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) {
  os << '{';
  for (auto v : vec) os << v << ',';
  os << '}';
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa) {
  os << '(' << pa.first << ',' << pa.second << ')';
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &mp) {
  os << '{';
  for (auto v : mp) os << v.first << "=>" << v.second << ',';
  os << '}';
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp) {
  os << '{';
  for (auto v : mp) os << v.first << "=>" << v.second << ',';
  os << '}';
  return os;
}
struct MyIO {
  MyIO() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} IO_OI;
map<int, int> factorize(int n) {
  map<int, int> ans;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ans[i]++;
      n /= i;
    }
  }
  if (n != 1) ans[n]++;
  return ans;
}
template <class T>
vector<T> calc_divisor(T n) {
  vector<T> res;
  res.push_back(n);
  for (T i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      res.push_back(i);
      T j = n / i;
      if (j != i) res.push_back(j);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
void solve() {
  ll n;
  cin >> n;
  auto mp = factorize(n);
  auto divs = calc_divisor(n);
  (void(0));
  if (mp.size() == 1) {
    for (int i = 0; i < (divs.size()); i++) cout << divs[i] << " ";
    cout << "\n" << 0 << "\n";
    return;
  }
  if (mp.size() == 2 and mp[divs[0]] == 1 and mp[divs[1]] == 1) {
    for (int i = 0; i < (divs.size()); i++) cout << divs[i] << " ";
    cout << "\n" << 1 << "\n";
    return;
  }
  vector<int> primes;
  for (auto [k, v] : mp) primes.push_back(k);
  set<int> st;
  for (int i = 0; i < (divs.size()); i++) st.insert(divs[i]);
  (void(0));
  (void(0));
  int nn = primes.size();
  cout << primes[0] * primes[nn - 1] << " ";
  st.erase(primes[0] * primes[nn - 1]);
  auto f = [&](ll k) {
    if (k > n) return false;
    if (st.count(k))
      return true;
    else
      return false;
  };
  for (int i = 0; i < (nn); i++) {
    cout << primes[i] << " ";
    st.erase(primes[i]);
    int next;
    if (f(primes[i] * primes[(i + 1) % nn]))
      next = primes[i] * primes[(i + 1) % nn];
    else if (f((ll)primes[i] * (ll)primes[i] * (ll)primes[(i + 1) % nn]))
      next = primes[i] * primes[(i + 1) % nn] * primes[i];
    else
      next = primes[i] * primes[(i + 1) % nn] * primes[(i + 1) % nn];
    if (i != nn - 1) st.erase(next);
    for (auto itr = st.begin(); itr != st.end();) {
      if ((*itr) % primes[i] == 0) {
        cout << (*itr) << " ";
        itr = st.erase(itr);
      } else
        itr++;
    }
    if (i != nn - 1) cout << next << " ";
  }
  cout << "\n" << 0 << "\n";
}
int main() {
  int num_query;
  cin >> num_query;
  while (num_query--) solve();
}