F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Pty loves string

Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 538    Accepted Submission(s): 200


Problem Description
Pty has a string S of length n consisting of lowercase English letters. He denotes the value of string T as the number of occurrences of T in string S.

Now he has Q queries, for each query he gives you x,y. Let the string T be the concatenation of the prefix of length x in the string S and its suffix of length y. He wants you to tell him the value of T.
 

Input
An integer T in the first line indicates the number of tests.

For each test,first line contains two integer n,Q - the length of S and the number of queries.

The second line contains string S of length n consisting of lowercase English letters.

For the next Q lines, each line contains two integers x,y.

$1\le T\le 5,1 \le n, Q \le 2 \times 10^5, 1 \le x, y \le n$
 

Output
For each test,output Q lines in total.

For each query, print the answer in one line.
 

Sample Input
1 6 3 ababaa 1 1 2 1 3 1
 

Sample Output
1 2 1
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-25 12:19:48, Gzip enabled