#433. Forgiving Matching
Forgiving Matching
Description
Little Q is now checking whether string matches . Two strings are considered matched if they have the same length, and there is no position that is different from .
However, Little Q is a kind man, he forgives every person who hurt him. What's more, he even forgives strings! He gives the string opportunities, if there are no more than positions that is different from , then Little Q will also consider the two strings matched. Note that both of the strings may contain the wildcard character '', which can match exactly one any character, in such a case this pair won't consume the forgiveness opportunities.
Let's denote as the number of substrings in string which matches , two substrings are considered different if they start in different places. You will be given two strings and , write a program to compute the value of for .
Format
Input
The first line contains a single integer (), the number of test cases. For each test case:
The first line of the input contains two integers and (), denoting the length of and the length of .
The second line contains a string of length .
The third line contains a string of length .
It is guaranteed that the sum of all is at most . Both and can only contain the characters in '', '', '', '', '', '', '', '', '', '', ''.
Output
For each test case, output lines, the -th () of which containing an integer, denoting the value of when .
Samples
1
5 3
012*4
1*3
1
1
3
3