
A string is said to be a generalised abbreviations string of ‘STR’ if we remove a substring of length ‘X’ from ‘STR’ and put the number ‘X’ at the place of the removed substring.
We can not remove two consecutive substrings or we can say generalised abbreviations will never have two consecutive numbers.
If ‘STR’ = “abc”,
Sorted generalized abbreviations of ‘STR’ are: [“1b1”, “1bc”, “2c”, “3”, “a1c”, “a2”, “ab1”, “abc”].
The first line of input contains a single integer T, representing the number of test cases.
Then the T test cases follow.
The first and the only line of each test case contains a string ‘STR’.
For every test case, print all the generalised abbreviations of ‘STR’ separated by a single space.
The output of each test case is printed in a separate line.
You don’t have to print anything. It has already been taken care of. Just implement the given function.
1<= T <=10
1<= |STR| <= 20
Where |STR| is length of String 'STR'.
Time limit: 1 sec
Complete Algorithm: