Special Sub Sequences - Beta
Submissions: 7   Accuracy:


  Max. Score:


Given a string S, print all ‘Special Sub Sequences’ of SFor Instance, “ab” has the following Special-SubSequences-: { “A”, “AB”, “Ab”, “B”, “a”, “aB”, “ab”, “b” }.

NOTE : Consider only the non-empty special Subsequences of S, as shown above.

Input : The first line of input conains number of testcases TEach testcase contains a single line denoting the string S.

Output : For each testcase you need to print two lines. In the 1st line print N, denoting the number of Special Sub Sequences of S.

In the 2nd line print N space separated integers denoting the Special Sub Sequences of S, in lexicographically increasing order.

1 <= T <= 100
1 <= |S| <= 10
The String S, contains only lower-case letters (i.e ‘a’ - ‘z’)

Example :
Input :


Output :
A AB Ab B a aB ab b

Explanation :
Self Explanatory

to report an issue on this page.