#P9873. J. Widely Known Problem
J. Widely Known Problem
J. Widely Known Problem
Problem Description
Given a string of length consisting of lowercase English letters. You are given patterns, where the -th pattern is (indices of start from ). Now, there are queries, and each query provides . For each query, you need to find how many that the -th pattern occurs in .
Input
The input consists of multiple test cases. The first line contains a single integer () - the number of test cases. Description of the test cases follows. The first line of each test case contains three integer (, ). The second line contains a string of length . Each of the following lines contains two integers (). Each of the following lines contains two integers (). It's guaranteed that , .
Output
For each query, print one integer - the number of patterns occur in the given substring.
Sample Input
2
5 2 2
abaab
3 4
4 5
2 4
1 5
3 2 3
aba
1 2
3 3
1 2
2 3
1 3
Sample Output
1
2
2
1
2
Source
2023“钉耙编程”中国大学生算法设计超级联赛(7)