import fileinput T = int(input()) def find(A,B): best_i = 0 best_j = 0 for i in range(len(A)): j=i l=0 while(j < len(A) and l < len(B) and A[j]==B[l]): j += 1 l += 1 if (j-i+1)>(best_j-best_i+1): best_i=i best_j=j return best_j - best_i l=1 for line in fileinput.input(): T=line.split( ) if(len(T)==3): if(l>1): print() A = T[0] B = T[1] t = int(T[2]) print("Case #{}: ".format(l), end='') l += 1 else: #test case Ap = A[:int(T[0])] Bs = B[len(B)-int(T[1]):] best = find(Ap,Bs) print(best, sep=" ", end=' ') print()