Welcome to ZOJ
Information
Select Problem
Runs
Ranklist
ZOJ Problem Set - 3143
Svetlozar's Sequences

Time Limit: 1 Second      Memory Limit: 32768 KB

A Svetlozar Sequence consists of positive int values greater than 9, written in decimal, where for any two consecutive terms, a and b, of the sequence, b is the smallest number which can be formed from a sequence of decimal digits which multiplied together equal a, i.e.,

For example, the first Svetlozar Sequence is 10, 25, 55. It starts with 10 which has the factors 1, 2, 5, and 10. Candidates for the next term include 25, 52, and 125; the smallest candidate is 25. The term 25 has factors 1, 5, and 25, and candidates for the next term include 55 and 155. For this sequence no more terms are possible after 55.

Write a program to compute a Svetlozar Sequence from the first value of the sequence, if possible.

Input

The first input line contains one positive integer n. Each of the next n input lines contains one positive integer which is proposed as a starting value for a Svetlozar Sequence.

Output

For each proposed starting value the output should be one line containing the first 10 terms of the Svetlozar Sequence (or fewer terms if the sequence is shorter). If the value cannot start a Svetlozar Sequence the output should be No sequence.

Sample Input

3
10
11
12

Sample Output

10 25 55
No sequence
12 26

Source: Northeast North Ameriaca Regional Contest 2007
Submit    Status