#Q22. 「一本通 1.3 例 4」Addition Chains

「一本通 1.3 例 4」Addition Chains

Description

Original source: ZOJ 1937

Given a sequence a0,a1...ama_0,a_1...a_m (where a0=1a_0 = 1, am=na_m = n, and a0<a1<a2<...<am1<ama_0 \lt a_1 \lt a_2 \lt ... \lt a_{m-1} \lt a_m). For each kk, it must satisfy ak=ai+aja_k = a_i + a_j (0i,jk10 \leq i, j \leq k-1, where ii and jj can be equal).

Given the value of nn, find the minimum value of mm (no need to output it) and the value of each term in such a sequence (there may be multiple valid sequences; output any one that satisfies the conditions).

Input Format

Multiple test cases, each line contains a positive integer nn.

The input ends with 00.

Output Format

For each test case, output a sequence of the smallest possible length that satisfies the conditions.

Sample 1

5
7
12
15
77
0

1 2 4 5
1 2 4 6 7
1 2 4 8 12
1 2 4 5 10 15
1 2 4 8 9 17 34 68 77

Constraints & Hints

1n100,1km1 \leq n \leq 100,1 \leq k \leq m