We have Infinitely Many Choclates and infinitely many children . And, We want to give them to children, But we will not give More than 'N' choclates to any one child. And, we want to give 'N' choclates to exactly 1 child.

And, We want to give thechoclates to as many children possible, in a beautiful sequence only.

**A beautiful sequence is an increasing sequence, in which a term A _{i} divides all A_{j}, where j>i. **

Forexample: 3, 6, 24 is a beautiful sequence of length 3.

- 3 divides 6 and 24
- 6 divides 24

We would give

- A
_{0}choclates to the first child, - A
_{1}choclates to the second child - ...and so on

We want maximum Children to get thechoclates. Output the Beautiful Sequence of maximum length.

**Input**

The first line contains T, the total number ofTestcases. Then Each of the next T lines, contains an integer denoting -'N'.

For each testcase, Print the beautiful sequence of

**1**≤**T**≤ 1000**1**≤**N**≤ 1000000

10

4

24

3

1 5 10

1 2 4

1 3 6 12 24

1 3

In the first case,N=10, 1 divides 5 and 10 5 divides 10. We can't give more than 10 choclates to any child, So We have to stop And this is the max. length achievable i.e.3.

Note that 1 2 10 is also a beautiful sequence of length 3, but we will choose that sequence containing more no. of choclates.i,e. 1 5 10

In the Third case,N=24 1 divides 3,6,12 and 24 3 divides 6,12, and 24. 6 divides 12 and 24 12 divides 24 We can't give more than 24 choclates to any child, So We have to stop and this is the max. length achievable i.e.5

In the Fourth Case , N=3 1 divides 3 . So We have to stop And this is the max. length achievable i.e. 2choclates, 3 is divisible by 1.

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

mantan_g | 267 |

tushki | 198 |

aksht7 | 182 |

ayush1101 | 128 |

namansharmacse17 | 110 |

ARUN_PUNDIR | 730 |

manishgupta8497 | 627 |

AMAN__JAIN | 625 |

Abhimanyu_kumar | 562 |

AJ786 | 541 |

blackshadows | 5335 |

Ibrahim Nash | 5223 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4584 |

Login to report an issue on this page.