#abc295f. [abc295_f]substr = S
[abc295_f]substr = S
Problem Statement
You are given a string consisting of digits and positive integers and for each of test cases. Solve the following problem.
For a positive integer , let us define as the number of contiguous substrings of the decimal representation of (without leading zeros) that equal .
For instance, if 22
, we have , , , and .
Find .
Constraints
- is a string consisting of digits whose length is between and , inclusive.
- and are integers satisfying .
Input
The input is given from Standard Input in the following format, where denotes the -th test case:
Each test case is in the following format:
Output
Print lines in total.
The -th line should contain an integer representing the answer to the -th test case.
Sample Input 1
6
22 23 234
0295 295 295
0 1 9999999999999999
2718 998244353 9982443530000000
869120 1234567890123456 2345678901234567
2023032520230325 1 9999999999999999
Sample Output 1
12
0
14888888888888889
12982260572545
10987664021
1
This input contains six test cases.
- In the first test case,
22
, , .- .
- .
- Thus, the answer is .
- In the second test case,
0295
, , .- Note that .