402795: GYM100883 F Print Mix Strings
Description
While I was working in the company, the internet broke. I didn't have anything to do without internet, so I decided to write this ACM problem.
We need to mix between two strings and also we should keep the same order for both strings.
Example: if we have s1 = "ab" and s2 = "cd", we can generate six strings:
abcd acbd
acdb cdab
cadb cabd
thank you for your help in ”Count Mix Strings” problem. now I can calculate the complexity and make input and output files. You will be given the two strings and you should print all the distinct strings that could be generated in the alphabetical order.
InputYour program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1 ≤ T ≤ 100).
Followed by the test cases, each test case is on one line. it contains two strings s1 and s2, both strings consist of at least 1 and at most 8 lower case English letters (from ‘a’ to ‘z’).
OutputFor each test case, print all the distinct strings that could be generated in the alphabetical order.
print a blank line after each test case.
ExamplesInput2Output
a aa
ab cd
aaa
abcd
acbd
acdb
cabd
cadb
cdab