#P8835. [传智杯 #3 决赛] 子串

[传智杯 #3 决赛] 子串

Background

disangan233 likes strings, so disangan333 wants you to find some strings that disangan233 likes.

Problem Description

In ChuanZhi’s development class, you are expected to develop a document processing software.

Given TT queries, each query provides 22 strings a,ba, b of lengths n,mn, m consisting only of English letters. Find the number of occurrences of aa in bb, where uppercase and lowercase of the same letter are not distinguished. Note that aa is a contiguous subsequence (substring) of bb.

For all testdata, T100T \leq 100, nm103\sum n \leq \sum m \leq 10^3. The strings consist only of uppercase or lowercase English letters.

Input Format

The input has a total of 3T+13T + 1 lines.

Line 11 contains 11 positive integer TT.

Then there are TT groups of input, each group has 33 lines.

Line 11 contains 22 positive integers n,mn, m.

Line 22 contains a string aa of length nn.

Line 33 contains a string bb of length mm.

Output Format

Output TT lines. Line ii outputs 11 integer, indicating the answer to query ii.

5
3 10
abc
abcabcabca
2 10
aa
AAaAaaAaAa
5 5
AbCdE
eDcBa
5 5
abcde
ABCDE
3 10
aba
ABaBaAbaBA
3
9
0
1
4

Hint

For the first group of input, it appears 33 times, namely [abc]abcabca, abc[abc]abca, abcabc[abc]a.

For the second group of input, it appears 99 times, namely [Aa]AaaAaAa, A[aA]aaAaAa, Aa[Aa]aAaAa, AaA[aa]AaAa, AaAa[aA]aAa, AaAaa[Aa]Aa, AaAaaA[aA]a, AaAaaA[aA]a, AaAaaAa[Aa].

Translated by ChatGPT 5