Description
Given two strings A and B, output the longest string X that can be created as a substring of A or a substring of B by reversing the order of the letters.
Input
The number of test cases T is entered. (1 <= T <= 20)
For each test case, two strings are entered on two lines, one per line.
All characters are entered in lowercase letters, and the length of the strings is 1,000 or less.
Output
For each input test case, print X line by line.
If there are multiple X's that satisfy the above conditions, print the one that comes first in alphabetical order.
3
pretty
women
walking
down
the
street