testcases = input()
for k in range(len(testcases)):
l1, l2 = input().split()
string1 = input()
string2 = input()
lenlist = []
res = [string1[i: j] for i in range(int(l1)) for j in range(i + 1, int(l1) + 1)]
for i in res:
if(i in string2):
lenlist.append(len(i))
print(lenlist)
print(max(lenlist))
此代码仅适用于一个测试用例,而当输入下一个测试用例时,则没有输出。