#P7467. [2017年杭电多校]Classic Quotation
[2017年杭电多校]Classic Quotation
Classic Quotation
Problem Description
When online chatting, we can save what somebody said to form his ''Classic Quotation''. Little Q does this, too. What's more? He even changes the original words. Formally, we can assume what somebody said as a string whose length is . He will choose a continuous substring of (or choose nothing), and remove it, then merge the remain parts into a complete one without changing order, marked as . For example, he might remove ''not'' from the string ''I am not SB.'', so that the new string will be ''I am SB.'', which makes it funnier. After doing lots of such things, Little Q finds out that string occurs as a continuous substring of very often. Now given strings and , Little Q has questions. Each question is, given and , Little Q will remove a substring so that the remain parts are and , what is the expected times that occurs as a continuous substring of if he choose every possible pair of equiprobably? Your task is to find the answer , and report to him. Note : When counting occurrences, can overlap with each other.
Input
The first line of the input contains an integer , denoting the number of test cases. In each test case, there are integers $n,m,k(1\leq n\leq 50000,1\leq m\leq 100,1\leq k\leq 50000)$ in the first line, denoting the length of , the length of and the number of questions. In the next line, there is a string consists of lower-case English letters. Then in the next line, there is a string consists of lower-case English letters. In the following lines, there are integers in each line, denoting a question.
Output
For each question, print a single line containing an integer, denoting the answer.
Sample Input
1
8 5 4
iamnotsb
iamsb
4 7
3 7
3 8
2 7
Sample Output
1
1
0
0
Source
2017 Multi-University Training Contest - Team 4