You're going to learn words from a dictionary for the next $$$q$$$ days. The dictionary is a string $$$S = s_1s_2 \cdots s_n$$$ of length $$$n$$$ consisting of lower-cased English letters, and a word is a substring of $$$S$$$.
On the $$$i$$$-th day, you will learn all the words which start with $$$S[l_i:r_i] = s_{l_i}s_{l_{i + 1}}\cdots s_{r_i}$$$ (that is to say, $$$S[l_i:r_i]$$$ is a prefix of these words). After each day, count how many different words you have already learned starting from the first day.
There are multiple test cases. The first line of the input contains an integer $$$T$$$ ($$$1 \le T \le 10^4$$$) indicating the number of test cases. For each test case:
The first line contains a string $$$s_1s_2 \cdots s_n$$$ of length $$$n$$$ ($$$1 \le n \le 2 \times 10^5$$$) consisting of lower-cased English letters, indicating the dictionary.
The second line contains an integer $$$q$$$ ($$$1 \le q \le 2 \times 10^5$$$), indicating the number of days you'll learn words.
For the following $$$q$$$ lines, the $$$i$$$-th line contains two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i \le r_i \le n$$$), indicating that on the $$$i$$$-th day, you will learn all the words with a prefix of $$$s_{l_i}s_{l_{i + 1}}\cdots s_{r_i}$$$.
It's guaranteed that neither the sum of $$$n$$$ nor the sum of $$$q$$$ of all test cases will exceed $$$2 \times 10^5$$$.
For each test case, output one line containing $$$q$$$ integers $$$c_1, c_2, \cdots c_q$$$ separated by a space, where $$$c_i$$$ is the number of different words you have learned from the $$$1$$$-st day to the $$$i$$$-th day (both inclusive).
2abcabd31 31 26 6aaa33 32 31 3
4 6 7 3 3 3
For the first sample test case:
For the second sample test case, you have learned all the words (a, aa, aaa) on the $$$1$$$-st day, so the answer is always $$$3$$$.
| Name |
|---|


