LCS means 'Longest Common Subsequence' that means two non-empty strings are given; you have to find the Longest Common Subsequence between them. Since there can be many solutions, you have to print the one which is the lexicographically smallest. Lexicographical order means dictionary order. For example, 'abc' comes before 'abd' but 'aaz' comes before 'abc'.
Input
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a blank line. The next two lines will contain two strings of length 1 to 100. The strings contain lowercase English characters only.
Output
For each case, print the case number and the lexicographically smallest LCS. If the LCS length is 0 then just print :(
.
Sample
Sample Input | Sample Output |
---|---|
3 ab ba zxcvbn hjgasbznxbzmx you kjhs | Case 1: a Case 2: zxb Case 3: :( |