


A Subsequence of a string is the one which is generated by deleting 0 or more letters from the string and keeping the rest of the letters in the same order.
The first line of input contains an integer ‘T’ denoting the number of test cases. Then T test cases follow.
The first and only line of each test case contains string 'STR'.
For each test case, print the subsequences of the string 'STR' separated by space.
The output of each test case is printed in a separate line.
The output strings can be returned in any order.
You don’t have to print anything, it has already been taken care of. Just implement the function.
1 <= T <= 10
1 <= |STR| <= 16
Where |STR| represents the length of the string 'STR'.
Time Limit: 1 sec
The idea is to use bit patterns from binary representation of 1 to 2^length - 1. For a string of length N, use the binary representation of all the numbers from 1 to (2^N - 1). Start from left (Most significant bit) to right (Least significant bit) and append characters from input string which corresponds to bit value 1 in binary representation to the current subsequence.
For example: “abc”
Binary representation from 1 to 2^3 - 1 that is 1 to 7
BinaryRepresentation for 1 is 001 which corresponds to substring “c”.
BinaryRepresentation for 2 is 010 which corresponds to substring “b”.
BinaryRepresentation for 3 is 011 which corresponds to substring “bc”.
BinaryRepresentation for 4 is 100 which corresponds to substring “a”.
BinaryRepresentation for 5 is 101 which corresponds to substring “ac”.
BinaryRepresentation for 6 is 110 which corresponds to substring “ab”.
BinaryRepresentation for 7 is 111 which corresponds to substring “abc”.
For every character of the input string there are two options, one is to include it in the current subsequence and another is not including it in the current subsequence. This will lead to all possible subsequences of the input string. This can be done using recursion.