Love Calculator

1 seconds
64 MB
Medium
LOJ-1013 Udebug Debug
English

Yes, you are developing a 'Love calculator' software. You are planning to write the software in a complex way such that nobody would be able to crack the exact behavior of the software.

Given two names, your software will generate the love score based on the names. The software requires the following things:

  1. The length of the shortest string that contains both the names as a subsequence.
  2. Total number of unique shortest strings which contain the names as a subsequence.

Once these two information are found, the software does a complex math and computes the score. The math is a secret and will be revealed another day. For now, your have to find these two values for a given pair of names.

Input

Input starts with an integer T (≤ 125), denoting the number of test cases.

Each of the test cases consists of two lines each containing a name. The names will contain no more than 30 capital letters.

Output

For each of the test cases, print one line containing the case number, followed by the shortest length of the string and the number of unique strings that satisfies the given conditions.

You can assume that the number of unique strings will always be less than 263. Look at the sample output for the exact format.

Sample

Sample Input Sample Output

3 USA USSR LAILI MAJNU SHAHJAHAN MOMTAJ

Case 1: 5 3 Case 2: 9 40 Case 3: 13 15

Notes

For the first case: USA and USSR, the shortest strings are [USASR, USSAR, USSRA]. So, the shortest length possible is 5 and there are 3 unique shortest strings containing both the names.