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;
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
template <typename T>
struct IsC {
  template <typename C>
  static char test(typename C::const_iterator*);
  template <typename C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&,
                                                             const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T>
using TS = tuple_size<tuple<T...>>;
template <size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type operator<<(
    ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template <size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template <size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type operator<<(
    ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template <typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << make_tuple(p.first, p.second);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream& o,
                                                             const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!0) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}
const int N = 5e4;
int lp[N + 1];
vector<int> pr;
void sieve() {
  for (auto i = (2); (i) < (N + 1); ++(i)) {
    if (!lp[i]) {
      lp[i] = i;
      pr.push_back(i);
    }
    for (int j = 0; j < (int)(pr).size() && pr[j] <= lp[i] && i * pr[j] <= N;
         ++j)
      lp[i * pr[j]] = pr[j];
  }
}
bool isPrime(int n) {
  if (n < N) return lp[n] == n;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
void solve() {
  int n;
  cin >> n;
  vector<pair<int, int>> pdivs;
  vector<int> divs;
  for (int i = 0, nn = n; i < (int)(pr).size() || nn > 1; ++i) {
    if (i == (int)(pr).size()) {
      pdivs.emplace_back(nn, 1);
      break;
    }
    int cnt = 0;
    for (; nn % pr[i] == 0; nn /= pr[i]) {
      ++cnt;
    }
    if (cnt) {
      pdivs.emplace_back(pr[i], cnt);
    }
  }
  if (0)
    std::cerr << " ["
              << "pdivs"
                 ": "
              << make_tuple(pdivs) << "] " << endl;
  if ((int)(pdivs).size() == 2 && pdivs[0].second == 1 &&
      pdivs[1].second == 1) {
    cout << n << ' ' << pdivs[0].first << ' ' << pdivs[1].first << endl;
    cout << 1 << endl;
    return;
  }
  vector<vector<int>> ex((int)(pdivs).size());
  vector<int> skiped;
  for (vector<int> idx((int)(pdivs).size(), 0);;) {
    ++idx.back();
    for (int j = (int)(pdivs).size() - 1; j > 0 && idx[j] > pdivs[j].second;
         --j) {
      idx[j] = 0;
      ++idx[j - 1];
    }
    if (idx[0] > pdivs[0].second) {
      break;
    }
    if (0)
      std::cerr << " ["
                << "idx"
                   ": "
                << make_tuple(idx) << "] " << endl;
    int val = 1;
    int last = -1;
    int cnt = 0;
    for (auto j = (0); (j) < (((int)(pdivs).size())); ++(j)) {
      if (idx[j]) {
        last = j;
        ++cnt;
      }
      for (auto _ = (0); (_) < ((idx[j])); ++(_)) {
        val *= pdivs[j].first;
      }
    }
    if (cnt == 2 &&
        (pdivs[last].first * pdivs[last - 1].first == val ||
         pdivs[last].first * pdivs[(last + 1) % (int)(pdivs).size()].first ==
             val)) {
      skiped.push_back(val);
    } else {
      ex[last].push_back(val);
    }
  }
  if (0)
    std::cerr << " ["
              << "skiped"
                 ": "
              << make_tuple(skiped) << "] " << endl;
  if (0)
    std::cerr << " ["
              << "ex"
                 ": "
              << make_tuple(ex) << "] " << endl;
  if ((int)(ex).size() == 1) {
    for (int i : ex[0]) {
      cout << i << ' ';
    }
  } else if ((int)(ex).size() == 2) {
    for (int i : ex[0]) {
      cout << i << ' ';
    }
    cout << ex[0][0] * ex[1][0] << ' ';
    for (int i : ex[1]) {
      cout << i << ' ';
    }
  } else {
    for (auto i = (0); (i) < (((int)(ex).size())); ++(i)) {
      for (int j : ex[i]) {
        cout << j << ' ';
      }
      cout << ex[i][0] * ex[(i + 1) % (int)(ex).size()][0] << ' ';
    }
  }
  cout << endl << 0 << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  sieve();
  int tt = 1;
  cin >> tt;
  for (auto t = (1); (t) < (tt + 1); ++(t)) {
    solve();
  }
  return 0;
}