Note — this problem is the easier version of the problem uwu. However, the solutions to the two problems are different.
Although school hasn't started for Ștefan for some time, a familiar sound filled his thoughts: uwuwuwuwuwu
.
So, he thought to use this opportunity to turn this sound into a good 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 subsequences uwu can be obtained in the interval if the characters in the interval are arranged suitably.
A subsequence defined by the chosen positions , , and (with ) is called uwu if u
, w
, u
.
Arrangements do not carry over from one query to another; in other words, all queries start from the initial string.
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 characters , of length . The following lines contain the queries, in the order they should be answered.
Note: It is recommended to add the following line of code at the beginning of the main()
function to speed up reading:
cin.tie(0);ios::sync_with_stdio(0);
Output data
Print lines, with the -th line containing the answer for the -th query.
Constraints and clarifications
# | Points | Constraints |
---|---|---|
0 | 0 | Example |
1 | 31 | |
2 | 69 | 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
100
6
8
12
27
36
1
27
Explanation
For the fourth query, we can arrange the characters in the interval as follows: uuwwwuu
.