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 <typename T, typename F>
string to_string(pair<T, F> p);
template <typename T, typename F, typename Tr>
string to_string(tuple<T, F, Tr> p);
template <typename T, typename F, typename Tr, typename Th>
string to_string(tuple<T, F, Tr, Th> p);
string to_string(string s) { return '"' + s + '"'; }
string to_string(char c) { return (string) "'" + c + "'"; }
string to_string(const char* p) { return to_string((string)p); }
string to_string(bool B) { return (B ? "true" : "false"); }
string to_string(vector<bool> v) {
  string res = "{";
  for (int i = 0; i < (int)v.size(); ++i) {
    if ((int)res.size() > 1) res += ", ";
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t T>
string to_string(bitset<T> bs) {
  return bs.to_string();
}
template <typename T>
string to_string(T v) {
  string res = "{";
  for (auto& el : v) {
    if ((int)res.size() > 1) res += ", ";
    res += to_string(el);
  }
  res += "}";
  return res;
}
template <typename T, typename F>
string to_string(pair<T, F> p) {
  return '(' + to_string(p.first) + ", " + to_string(p.second) + ')';
}
template <typename T, typename F, typename Tr>
string to_string(tuple<T, F, Tr> p) {
  return '(' + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ')';
}
template <typename T, typename F, typename Tr, typename Th>
string to_string(tuple<T, F, Tr, Th> p) {
  return '(' + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ')';
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const int N = sqrt((int)1e9 + 1) + 1;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long T;
  cin >> T;
  while (T--) {
    long long n;
    cin >> n;
    long long tn = n;
    vector<pair<long long, long long>> divs;
    for (long long i = 2; i < N; ++i) {
      if (n % i == 0) divs.emplace_back(i, 0);
      while (n % i == 0) {
        n /= i;
        ++divs.back().second;
      }
    }
    if (n > 1) {
      divs.emplace_back(n, 1);
    }
    n = tn;
    if ((long long)divs.size() == 1) {
      long long cur = divs[0].first;
      while (divs[0].second-- > 0) {
        cout << cur << ' ';
        cur *= divs[0].first;
      }
      cout << '\n' << 0 << '\n';
      continue;
    }
    if ((long long)divs.size() == 2 && divs[0].second == 1 &&
        divs[1].second == 1) {
      cout << divs[0].first << ' ' << divs[1].first << ' '
           << divs[0].first * divs[1].first << '\n';
      cout << 1 << '\n';
    } else {
      vector<long long> ans;
      map<long long, long long> vis;
      auto add = [&](long long x) {
        if (vis[x]) return;
        vis[x] = true;
        ans.push_back(x);
      };
      if ((long long)divs.size() != 2) {
        for (long long i = 0; i < n; ++i) {
          long long bef = divs[(i ? i - 1 : (long long)divs.size() - 1)].first;
          add(bef * divs[i].first);
          if (i < (long long)divs.size() - 1)
            vis[divs[i].first * divs[i + 1].first] = true;
          long long sy = divs[i].second;
          while (sy--) {
            n /= divs[i].first;
          }
          sy = divs[i].second;
          vector<long long> tmp;
          for (long long j = 1; j * j <= n; ++j) {
            if (n % j == 0) {
              tmp.push_back(j);
              tmp.push_back(n / j);
            }
          }
          if ((long long)tmp.size() > 2 &&
              tmp.back() == tmp[(long long)tmp.size() - 2])
            tmp.pop_back();
          long long curt = divs[i].first;
          for (long long j = 0; j < sy; ++j) {
            for (auto el : tmp) {
              add(el * curt);
            }
            if (j < sy - 1) curt *= divs[i].first;
          }
          if (i < (long long)divs.size() - 1)
            vis[divs[i].first * divs[i + 1].first] = false;
        }
      } else {
        for (long long i = 0; i < n; ++i) {
          long long bef = divs[(i ? i - 1 : (long long)divs.size() - 1)].first;
          add(bef * divs[i].first *
              (i == 0 ? (divs[i].second > 1 ? divs[i].first : divs[i ^ 1].first)
                      : 1));
          if (i < (long long)divs.size() - 1)
            vis[divs[i].first * divs[i + 1].first] = true;
          long long sy = divs[i].second;
          while (sy--) {
            n /= divs[i].first;
          }
          sy = divs[i].second;
          vector<long long> tmp;
          for (long long j = 1; j * j <= n; ++j) {
            if (n % j == 0) {
              tmp.push_back(j);
              tmp.push_back(n / j);
            }
          }
          if ((long long)tmp.size() > 2 &&
              tmp.back() == tmp[(long long)tmp.size() - 2])
            tmp.pop_back();
          long long curt = divs[i].first;
          for (long long j = 0; j < sy; ++j) {
            for (auto el : tmp) {
              add(el * curt);
            }
            if (j < sy - 1) curt *= divs[i].first;
          }
          if (i < (long long)divs.size() - 1)
            vis[divs[i].first * divs[i + 1].first] = false;
        }
      }
      add(divs[0].first * divs.back().first);
      for (auto el : ans) cout << el << ' ';
      cout << '\n';
      cout << 0 << '\n';
    }
  }
}