CF BUDDY
← Problems·

1454D · Number into Sequence

1300 · constructive algorithms, math, number theory

Problem: You are given an integer nn (n>1n > 1).

Your task is to find a sequence of integers a1,a2,,aka_1, a_2, \ldots, a_k such that:

  • each aia_i is strictly greater than 11;
  • a1a2ak=na_1 \cdot a_2 \cdot \ldots \cdot a_k = n (i. e. the product of this sequence is nn);
  • ai+1a_{i + 1} is divisible by aia_i for each ii from 11 to k1k-1;
  • kk is the maximum possible (i. e. the length of this sequence is the maximum possible).

If there are several such sequences, any of them is acceptable. It can be proven that at least one valid sequence always exists for any integer n>1n > 1.

You have to answer tt independent test cases.

Input Format: The first line of the input contains one integer tt (1t50001 \le t \le 5000) — the number of test cases. Then tt test cases follow.

The only line of the test case contains one integer nn (2n10102 \le n \le 10^{10}).

It is guaranteed that the sum of nn does not exceed 101010^{10} (n1010\sum n \le 10^{10}).

Output Format: For each test case, print the answer: in the first line, print one positive integer kk — the maximum possible length of aa. In the second line, print kk integers a1,a2,,aka_1, a_2, \ldots, a_k — the sequence of length kk satisfying the conditions from the problem statement.

If there are several answers, you can print any. It can be proven that at least one valid sequence always exists for any integer n>1n > 1.

Sample Cases

Case 1

Input

4
2
360
4999999937
4998207083

Output

1
2 
3
2 2 90 
1
4999999937 
1
4998207083

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback