Problems
Elsie is trying to describe her favorite USACO contest to Bessie, but Bessie is having trouble understanding why Elsie likes it so much. Elsie says "And It's mooin' time! Who wants a mooin'? Please, I just want to do USACO".
Bessie still doesn't understand, so she transcribes Elsie's description in a string of length
A triplet
FJ bends string
In other words, the value of the triplet is
Bessie asks you
Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long long" in C/C++).
Input
The first line contains two integers
The following line contains
The following
Output
Output the answer for each query on a new line.
Example
12 5
abcabbacabac
1 12
2 7
4 8
2 5
3 10
28
6
1
-1
12
For the first query, (
For the third query, (
For the fourth query, there exists no (