Although Stefan hasn't started school for some time, a familiar sound has captured his thoughts: uwuwuwuwuwu
.
Therefore, he thought to use this opportunity to turn this sound into a problem for RoAlgo Back to School!
Task
Given a string indexed from containing only the letters u
and w
, as well as queries of the form , determine for each query how many uwu subsequences exist in the interval .
A subsequence defined by chosen positions , , and (with ) is called uwu if u
, w
, u
.
Input data
The first line contains two integers, and , representing the length of the string and the number of queries. The next line contains the string , of length . The next lines contain the queries, in the order they need to be answered.
Note! It is recommended to add the following line of code at the beginning of the main()
function to speed up reading the input:
cin.tie(0);ios::sync_with_stdio(0);
Output data
Print lines, where line contains the answer to the -th query.
Constraints and clarifications
# | Points | Constraints |
---|---|---|
0 | 0 | Example |
1 | 21 | |
2 | 17 | There are at most characters equal to w |
3 | 23 | |
4 | 39 | No additional constraints |
Example
stdin
14 8
uuwuwuuuwwuuuu
1 14
5 10
8 13
3 9
4 12
2 11
4 6
1 9
stdout
85
0
6
3
21
23
1
17
Explanation
For the fourth query, the triplets that form uwu subsequences are , , .