Striking String Problem
时间限制:C/C++/Rust/Pascal 8秒,其他语言16秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
64bit IO Format: %lld

题目描述

NIO is given two strings S and T consisting of lowercase letters, an integer k and 2k integers .


Define . He has q queries, each described by two integers x and y. For a query, he wants to know the number of times that T appears in . Help him!
  • is .
  • is .

输入描述:

The first line contains a single string .

The second line contains a single string .

The third line contains two integers k and .

Each of the next k lines contains two integers l_i and .

Each of the next q lines contains two integers x_i and .

输出描述:

Print q lines. The i-th of them contains a single integer - the answer to the i-th query.
示例1

输入

复制
abaaba
abaa
8 10
1 6
4 6
3 6
2 4
5 6
2 2
5 5
1 4
1 24
21 24
1 15
1 23
6 6
4 7
1 8
8 16
16 23
7 20

输出

复制
5
1
3
4
0
1
2
1
0
2

说明

U = \texttt{abaabaabaaababaababbabaa}