BETA

Difficulty Level: Easy

Submissions: 108 Accuracy:

25%

Count ways to increase LCS length of two strings by one
     

Given two strings of lower alphabet characters, we need to find the number of ways to insert a character in the first string such that length of LCS of both strings increases by one.

 

Input:

The first line of the contains T denoting the number of testcases. Then T testcases follow. The first line of each test case contains integers N and M denoting the length of strings str1 and str2.

The second line of each test case contains the strings str1 and str2 consisiting of only lower case alphabets.


Output:

Print the answer for each test case in a new line.


Constraints:

1<= T <=100

1<= N, M <=100


Example:

Input:

1

5 3

abab abc

Output:

3

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Sujnesh Mishra

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.