All Submissions


Given two strings with all distinct characters, print all interleaved strings in lexographical order.
Interleaving of string means the final string contains all the characters in both the strings and the relative order of the characters of individual strings remain the same.

Try doing it without using sets or first generating all strings and then sorting it.

Input
The first line contains a single integer T, the number of test cases. T lines follow containing two string each str1 and str2.

Output

Constraint
T <= 10
1 <= Length(str1) , Length(str2) <= 14
2 <= Length(str1) + Length(str2) <= 15

Sample Input
2
ad cb
x y


Sample Output
acbd
acdb
adcb
cabd
cadb
cbad
xy
yx


Problem Setter : Shikhar Sharad
Problem Tester : Arjun Singh Bhatia


Languages: Brain,C,C++,Java,Pascal,Perl,PHP,Python,Ruby,Text

Time Limit: 3 Second(s)
Score: 0 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0