This page is still under construction.

Parts of this page are still being built. What you see may change.

Euler's Problem

Time limit1sMemory limit128 MB

Summary
Given n, list every x with Euler phi(x) equal to n in increasing order, or report none.
Level

Hard8 of 10

Topics
Number theory, Backtracking, Recursion
Solved
No attempts yet

Problem

Leonhard Euler (1707-1783) was a great mathematician. This problem uses one of the functions named after him, the Euler φ\varphi function.

For a natural number nn, the value of φ\varphi at nn is the count of numbers kk (1≤k≤n1 \le k \le n) that are coprime to nn. Two numbers are coprime when they have no common divisor greater than 11. For example φ(6)=2\varphi(6) = 2, because 11 and 55 are coprime to 66 while 22, 33, 44 and 66 are not.

Had Euler lived on, he might have posed this: for a given natural number nn, find every natural number xx that satisfies φ(x)=n\varphi(x) = n.

Input

The first line contains one natural number tt (1≤t≤51 \le t \le 5), the number of data sets. Each of the next tt lines describes one data set and holds a single natural number nn (1≤n≤10101 \le n \le 10^{10}).

Output

Print the answers for the data sets in the order they appear in the input. The answer for one data set takes two lines. The first line holds the number of solutions. The second line holds every solution of the equation in increasing order. When the equation has no solution, leave the second line of that data set's answer empty.

Examples1

  1. Example 1

    Input
    4
    8
    10
    13
    6
    
    Expected output
    5
    15 16 20 24 30
    2
    11 22
    0
    
    4
    7 9 14 18