#P9873. J. Widely Known Problem

J. Widely Known Problem

J. Widely Known Problem

Problem Description

Given a string ss of length nn consisting of lowercase English letters. You are given mm patterns, where the ii-th pattern is s[liri]s[l_i \dots r_i] (indices of ss start from 11). Now, there are qq queries, and each query provides [Li,Ri][L_i, R_i]. For each query, you need to find how many jj that the jj-th pattern occurs in s[LiRi]s[L_i \dots R_i].

Input

The input consists of multiple test cases. The first line contains a single integer TT (1T101 \le T \le 10) - 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, q (1n5×1051\leq n\leq 5\times 10^5, 1m,q1061\leq m,q\leq 10^6). The second line contains a string ss of length nn. Each of the following mm lines contains two integers li,ril_i, r_i (1lirin1 \le l_i \le r_i \le n). Each of the following qq lines contains two integers Li,RiL_i, R_i (1LiRin1 \le L_i \le R_i \le n). It's guaranteed that n9×105\sum n \leq 9\times10^5, m,q2×106\sum m,\sum q\leq 2\times 10^6.

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)