Given a positive integer **n**, generate all possible unique ways to represent **n** as sum of positive integers. The output should be printed in lexicographically decreasing order partitions. For example, if given number is 52, then 52 itself should be printed first, then 51 1, then 50 2, ... and at the end partition with all 1s.

**Note : ** 2+1 and 1+2 are considered as duplicates.

**Input:**

The first line of input contains an integer **T **denoting the number of test cases.

The first line of each test case is** N**.

**Output:**

Print all possible unique ways to represent **n** as sum of positive integers.

**Constraints:**

1 ≤ T ≤ 20

1 ≤ N ≤ 30

**Example:**

**Input**

2

3

4

**Output**

3 2 1 1 1 1

4 3 1 2 2 2 1 1 1 1 1 1

**Explanation**

For n=4

4

3 1

2 2

2 1 1

1 1 1 1

These 5 possible ways are there so that we can get the sum 4 .

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.

d_Coder00 | 134 |

Astikeysingh | 128 |

dungeon_master1299 | 126 |

rajendrashekhawat063 | 115 |

VivSisMMM | 112 |

Pulkit__Sharma__ | 646 |

Anirban166 | 531 |

abducodes | 508 |

Found_me | 474 |

Sathvik Avasarala | 418 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4559 |

Login to report an issue on this page.