问题 J: Widely Known Problem

内存限制:720 MB 时间限制:20 S
题面:传统 评测方式:文本比较 上传者:
提交:2 通过:1

题目描述

Given a string ss of length n consisting of lowercase English letters.

You are given m patterns, where the i-th pattern is s[liri] (indices of s start from 1).

Now, there are q queries, and each query provides [Li,Ri]. For each query, you need to find how many j that the j-th pattern occurs in s[LiRi].

 

输入格式

The input consists of multiple test cases. The first line contains a single integer T(1T10) - the number of test cases. Description of the test cases follows.

The first line of each test case contains three integer n, m, qn,m( 1n5×1051m,q106).

The second line contains a string ss of length n.

Each of the following mm lines contains two integers li,ri (1lirin).

Each of the following q lines contains two integers Li,Ri (1LiRin).

It's guaranteed that n9×105,m,q2×106.

 

输出格式

For each query, print one integer - the number of patterns occur in the given substring.

输入样例 复制

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

输出样例 复制

1
2
2
1
2

分类标签