Luka is not paying attention in class again, while the teacher is explaining redox reactions. Instead of paying attention, he is playing with analog dials.
An analog dial is a small device which always shows one digit between
Luka has
Luka's game starts with him setting the dials in some starting configuration, which he then writes onto
the first sheet. Luka then does the following
- Choose two integers
and and write them down on the first sheet. - Calculate the sum of numbers on dials numbered between
and (inclusive), and write the sum down on the second sheet. - Press the button once on all dials numbered between
and .
Just as he had finished his game, the teacher noticed him, and took away all his dials and the second sheet of paper.
Given the contents of the first sheet, help him calculate the numbers on the second sheet.
Input Specification
The first line contains two integers
The second line contains the initial configuration of the dials,
Each of the following
Output Specification
Output
Scoring
In 30% of all test cases, the numbers
Sample Input 1
4 3
1234
1 4
1 4
1 4
Sample Output 1
10
14
18
Sample Input 2
4 4
1234
1 1
1 2
1 3
1 4
Sample Output 2
1
4
9
16
Sample Input 3
7 5
9081337
1 3
3 7
1 3
3 7
1 3
Sample Output 3
17
23
1
19
5
Comments