

If S = "ababa", and P = "ab", then "ab" occurs twice in "ababa".
The string only consists of lowercase English alphabets.
The first line of input contains T, the number of test cases.
The first line of each test case contains two integers N and M, the length of string S and P respectively.
The second line of each test case contains the string S.
The third line of each test case contains the string P.
The only line of output of each test case should contain an integer denoting the number of occurrences of P in S.
You don’t need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 100
1 <= N, M <= 10^4
Time Limit: 1 sec
A basic approach is to check all substrings of string ‘S’ and see if that substring is equal to ‘P’ or not. Let’s see how we’ll do this.
For example- String S = ababa and String P = ab
Here N = 5 and M = 2
As we are supposed to find the number of occurrences of 'P' in ‘S’ in linear time. We can do this by maintaining a Z array. The Z array for any string 'S' of length 'N' is an array of size 'N' where the ith element is equal to the greatest number of characters starting from the position ‘i’ that coincide with the first characters of ‘S’.
The idea here is to concatenate both 'S' and 'P' and make a string “P#S”, where ‘#’ is a special character that we are using. Now, for this concatenated string we will make a Z array. In this Z array, if the value at any index(z[i]) is equal to ‘M', we increment our answer(initially=0) by 1 because this indicates that ‘P’ is present at that index.
Let’s understand how we will reach our final answer using the following points.
For example- String S = abba and String P = ab
Here N = 4 and M = 2