String

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 4681
64-bit integer IO format: %I64d      Java class name: Main

Description

Given 3 strings A, B, C, find the longest string D which satisfy the following rules:
a) D is the subsequence of A
b) D is the subsequence of B
c) C is the substring of D
Substring here means a consecutive subsequnce.
You need to output the length of D.

Input

The first line of the input contains an integer T(T = 20) which means the number of test cases.
For each test case, the first line only contains string A, the second line only contains string B, and the third only contains string C.
The length of each string will not exceed 1000, and string C should always be the subsequence of string A and string B.
All the letters in each string are in lowercase.

Output

For each test case, output Case #a: b. Here a means the number of case, and b means the length of D.

Sample Input

2
aaaaa
aaaa
aa
abcdef
acebdf
cf

Sample Output

Case #1: 4
Case #2: 3

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .