Power Set

Medium

You are given an integer array nums, composed of unique elements. Find its power set.
Power set is the collection of all possible subsets of a given set.
The result must not contain duplicates and can be in any order.

Example
nums: [1, 2, 3]
Power Set: [[], [1], [1,2], [1,2,3], [1,3], [2], [2,3], [3]]

Testing

Input Format

The first line contains an integer ‘T’ denoting the number of test cases.

For each test case, the input has two lines with the following:

  • An integer n, denoting the size of the array nums.
  • n space-separated integers denoting the elements of the array nums.

Output Format

For each test case, the output has m lines, where m is the number of subsets of nums.
Each line has space-separated integers denoting the subset.

Sample Input

2
2
1 2
3
1 2 3

Expected Output


1 
1 2 
2 

1 
1 2 
1 2 3 
1 3 
2 
2 3 
3 

Constraints

1 <= T <= 10
1 <= n <= 10
1 <= numsi <= 10

Editorial Link: Editorial