Under construction

Still being built. Things may change

Based Zeros

Time limit2sMemory limit1024 MB

Summary
For each n, find the largest number of zero digits that n can have in any base from 2 to n, and list every base that reaches that count.
Level

Medium7 of 10

Topics
Number theory, Math, Brute force
Solved
No attempts yet

Problem

Barbara has always known how to write integers in the decimal system (base ten), using the digits 0,1,2,…,90, 1, 2, \ldots, 9. Recently she learned that for any integer base b≥2b \ge 2, she can also write integers in base bb, using the symbols with values from 00 to b−1b-1 as digits.

Barbara's favorite digit is 00. Luckily, it looks the same in all bases.

Today Barbara is playing with a positive integer nn. She wonders in which bases the representation of nn contains the most zeros. Find all such bases.

Input

The first line contains the number of test cases tt (1≤t≤10001 \le t \le 1000). Each test case is a single line containing one integer nn (2≤n≤10182 \le n \le 10^{18}).

Output

For each test case, print two integers kk and mm on the first line. Here kk is the maximum number of zeros that the representation of nn can have in any base, and mm is the number of bases that reach it.

On the second line, print the mm bases b1,b2,…,bmb_1, b_2, \ldots, b_m in increasing order (2≤b1<b2<⋯<bm≤n2 \le b_1 < b_2 < \cdots < b_m \le n).

Hint

The representations with the maximum number of zeros for the sample cases are:

  • 11=10112=1023=101111 = \mathtt{1011}_2 = \mathtt{102}_3 = \mathtt{10}_{11} (one zero)
  • 1007=11010223=1007101007 = \mathtt{1101022}_3 = \mathtt{1007}_{10} (two zeros)
  • 239=111011112=10356=10E15=10239239 = \mathtt{11101111}_2 = \mathtt{1035}_6 = \mathtt{10E}_{15} = \mathtt{10}_{239} (one zero)

In 239=10E15239 = \mathtt{10E}_{15}, E\mathtt{E} is a digit with value 1414.

Examples1

  1. Example 1

    Input
    3
    11
    1007
    239
    
    Expected output
    1 3
    2 3 11
    2 2
    3 10
    1 4
    2 6 15 239