Juggler Sequence is a series of integer number in which the first term starts with a positive integer number *a* and the remaining terms are generated from the immediate previous term using the below recurrence relation:

Given a number *N* your task is to print the space separated Juggler Sequence for this number as the first term of the sequence.

Examples:

```
Input: 9
Output: 9, 27, 140, 11, 36, 6, 2, 1
We start with 9 and use above formula to get
next terms.
Input: 6
Output: 6, 2, 1
```

**Input:**

The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each line contains an integer N.

**Output:**

For each test case in a new line print the space separated juggler sequence for number N as the first term of the sequence.

**Constraints:**

1<=T<=100

1<=N<=100

**Example:
Input:**

2

9

6

9 27 140 11 36 6 2 1

6 2 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.

VISHESHA SADU | 27 |

ghanshyam648 | 25 |

Biswajit3 | 21 |

karthik_kasaragadda | 20 |

tanya_sharma | 18 |

KshatriyaYash | 1066 |

nikhil_sojan | 978 |

lonecoder | 935 |

mazumderrohit8 | 864 |

SumitSingh27 | 832 |

blackshadows | 5327 |

Ibrahim Nash | 5215 |

akhayrutdinov | 5111 |

mb1973 | 4468 |

Quandray | 4444 |

Login to report an issue on this page.