AvavaAva
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
AvavaAva
Time limit: 1 seconds
Memory limit: 512 megabytes
Problem Statement
Diana ask a simple question to Ava :
A string is given, each query will give an interval , you need to answer how many subsequences of string "AVA" are in this interval.
Since the answer may be very large, you only need to print the result modulo .
A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e, "ace"
is a subsequence of "abcde"
while "aec"
is not).
Input
The first line contains two integers denoting the length of string and the number of queries.
The second line contains a string . It is guaranteed that each character in is 'A' or 'v'.
In the following lines, each line contains two integers denoting a query.
Output
Print lines, each line contains a integer, denoting the answer to each query modulo .
8 5
AvAvAAvA
1 3
1 5
2 4
1 8
5 8
1
4
0
14
2
5 2
AvvvA
1 5
1 4
3
0