Power Set
##### Submissions: 3820   Accuracy: 19.6%   Difficulty: Easy   Marks: 2
Associated Course(s):   Interview Preparation

Given a string of length n, print all the possible subsets of the string in a lexiographically-sorted order.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains an integer n denoting the length of the string. The second line of each test case contains the string consisting of lower-case english alphabets.

Output:
For each testcase, in a new line, print all the possible subsets (except the null subset) in a sorted order with a space between each subset.

Constraints:
1 <= T <= 100
1 <= n <= 16

Example:
Input:
1
3
abc
Output:
a ab abc ac b bc c

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Sujnesh Mishra
Author: sujnesh

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.